@@ -262,32 +262,24 @@ static int wait_for_quote_completion(struct tdx_quote_buf *quote_buf, u32 timeou
262
262
return (i == timeout ) ? - ETIMEDOUT : 0 ;
263
263
}
264
264
265
- static int tdx_report_new (struct tsm_report * report , void * data )
265
+ static int tdx_report_new_locked (struct tsm_report * report , void * data )
266
266
{
267
267
u8 * buf ;
268
268
struct tdx_quote_buf * quote_buf = quote_data ;
269
269
struct tsm_desc * desc = & report -> desc ;
270
270
int ret ;
271
271
u64 err ;
272
272
273
- /* TODO: switch to guard(mutex_intr) */
274
- if (mutex_lock_interruptible (& quote_lock ))
275
- return - EINTR ;
276
-
277
273
/*
278
274
* If the previous request is timedout or interrupted, and the
279
275
* Quote buf status is still in GET_QUOTE_IN_FLIGHT (owned by
280
276
* VMM), don't permit any new request.
281
277
*/
282
- if (quote_buf -> status == GET_QUOTE_IN_FLIGHT ) {
283
- ret = - EBUSY ;
284
- goto done ;
285
- }
278
+ if (quote_buf -> status == GET_QUOTE_IN_FLIGHT )
279
+ return - EBUSY ;
286
280
287
- if (desc -> inblob_len != TDX_REPORTDATA_LEN ) {
288
- ret = - EINVAL ;
289
- goto done ;
290
- }
281
+ if (desc -> inblob_len != TDX_REPORTDATA_LEN )
282
+ return - EINVAL ;
291
283
292
284
memset (quote_data , 0 , GET_QUOTE_BUF_SIZE );
293
285
@@ -298,26 +290,23 @@ static int tdx_report_new(struct tsm_report *report, void *data)
298
290
ret = tdx_do_report (KERNEL_SOCKPTR (desc -> inblob ),
299
291
KERNEL_SOCKPTR (quote_buf -> data ));
300
292
if (ret )
301
- goto done ;
293
+ return ret ;
302
294
303
295
err = tdx_hcall_get_quote (quote_data , GET_QUOTE_BUF_SIZE );
304
296
if (err ) {
305
297
pr_err ("GetQuote hypercall failed, status:%llx\n" , err );
306
- ret = - EIO ;
307
- goto done ;
298
+ return - EIO ;
308
299
}
309
300
310
301
ret = wait_for_quote_completion (quote_buf , getquote_timeout );
311
302
if (ret ) {
312
303
pr_err ("GetQuote request timedout\n" );
313
- goto done ;
304
+ return ret ;
314
305
}
315
306
316
307
buf = kvmemdup (quote_buf -> data , quote_buf -> out_len , GFP_KERNEL );
317
- if (!buf ) {
318
- ret = - ENOMEM ;
319
- goto done ;
320
- }
308
+ if (!buf )
309
+ return - ENOMEM ;
321
310
322
311
report -> outblob = buf ;
323
312
report -> outblob_len = quote_buf -> out_len ;
@@ -326,12 +315,16 @@ static int tdx_report_new(struct tsm_report *report, void *data)
326
315
* TODO: parse the PEM-formatted cert chain out of the quote buffer when
327
316
* provided
328
317
*/
329
- done :
330
- mutex_unlock (& quote_lock );
331
318
332
319
return ret ;
333
320
}
334
321
322
+ static int tdx_report_new (struct tsm_report * report , void * data )
323
+ {
324
+ scoped_cond_guard (mutex_intr , return - EINTR , & quote_lock )
325
+ return tdx_report_new_locked (report , data );
326
+ }
327
+
335
328
static bool tdx_report_attr_visible (int n )
336
329
{
337
330
switch (n ) {
0 commit comments