@@ -262,32 +262,24 @@ static int wait_for_quote_completion(struct tdx_quote_buf *quote_buf, u32 timeou
262262 return (i == timeout ) ? - ETIMEDOUT : 0 ;
263263}
264264
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 )
266266{
267267 u8 * buf ;
268268 struct tdx_quote_buf * quote_buf = quote_data ;
269269 struct tsm_desc * desc = & report -> desc ;
270270 int ret ;
271271 u64 err ;
272272
273- /* TODO: switch to guard(mutex_intr) */
274- if (mutex_lock_interruptible (& quote_lock ))
275- return - EINTR ;
276-
277273 /*
278274 * If the previous request is timedout or interrupted, and the
279275 * Quote buf status is still in GET_QUOTE_IN_FLIGHT (owned by
280276 * VMM), don't permit any new request.
281277 */
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 ;
286280
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 ;
291283
292284 memset (quote_data , 0 , GET_QUOTE_BUF_SIZE );
293285
@@ -298,26 +290,23 @@ static int tdx_report_new(struct tsm_report *report, void *data)
298290 ret = tdx_do_report (KERNEL_SOCKPTR (desc -> inblob ),
299291 KERNEL_SOCKPTR (quote_buf -> data ));
300292 if (ret )
301- goto done ;
293+ return ret ;
302294
303295 err = tdx_hcall_get_quote (quote_data , GET_QUOTE_BUF_SIZE );
304296 if (err ) {
305297 pr_err ("GetQuote hypercall failed, status:%llx\n" , err );
306- ret = - EIO ;
307- goto done ;
298+ return - EIO ;
308299 }
309300
310301 ret = wait_for_quote_completion (quote_buf , getquote_timeout );
311302 if (ret ) {
312303 pr_err ("GetQuote request timedout\n" );
313- goto done ;
304+ return ret ;
314305 }
315306
316307 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 ;
321310
322311 report -> outblob = buf ;
323312 report -> outblob_len = quote_buf -> out_len ;
@@ -326,12 +315,16 @@ static int tdx_report_new(struct tsm_report *report, void *data)
326315 * TODO: parse the PEM-formatted cert chain out of the quote buffer when
327316 * provided
328317 */
329- done :
330- mutex_unlock (& quote_lock );
331318
332319 return ret ;
333320}
334321
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+
335328static bool tdx_report_attr_visible (int n )
336329{
337330 switch (n ) {
0 commit comments