[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] x86/HVM: correct hvmemul_map_linear_addr() for multi-page case


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 31 Aug 2023 09:14:14 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=83eCGobUtZzKSOusBp0Da35TwErztEHHH8xzXkDxB2Y=; b=ie5gpUySao3npO5fY/mlRpy4uSq37BfcX7177ur7fc+bhI8gPdM5MBsxSIhnYs+Zb88mMOgIgjLks79YWUmHLwvymtwsvm9L6CZaMMWZ77yWJ0ndBusqmY4ELioTLQgmco8YH9ZqKreFfYgZ8fo+SSClUMilT6sNJ4SJsX3Fjdgb25J73oa5wxhUCEh1gWjQ4FTqQUouOnMsQsADCEXxc5LQynatkk7uG4CRzD0D9XD42m24jy4rY9EBuXgVx6cQHV0hdrPlMQxpjAcnR177tlQkBramqMGGPsThPKnRF9Boruv6UTGk7jiawU8VAvH+3l0GJ8f4qeYryh03dd5XMQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h2SPc1PmhqmkHcg3yA65aqPrToMN5Vfp4XTHQkvbecUvfVpHvu8Q+jrSXqZVu5j3ZbOkmhB0wQtWH2NqutlCCY7biddshusB9vCokldSKvgUXM1M0Oa+a55NIZwsFuve77inI6hT84VRTH0uGziX8RlNDsqJngwssLjx0C49G/moAr9tno18HPOUTRIc5uS2UDVyfiLAkS8goei8Bd4BPHnRJ+9XZnz4kCiEgmeYnPZKks79WTcXSkLVYK0OmeifN40q0Qi/xnu0vy2NvmDJ1kjo+GdpsVGhjzB2rYW2yNfugcWj7AU54PjFqL4HH+SoVWdmR+mVBWca72u5HN31Og==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul.durrant@xxxxxxxxxx>
  • Delivery-date: Thu, 31 Aug 2023 07:14:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 30.08.2023 16:30, Roger Pau Monné wrote:
> On Wed, Sep 12, 2018 at 03:09:35AM -0600, Jan Beulich wrote:
>> The function does two translations in one go for a single guest access.
>> Any failure of the first translation step (guest linear -> guest
>> physical), resulting in #PF, ought to take precedence over any failure
>> of the second step (guest physical -> host physical).
> 
> If my understanding is correct, this is done so that any #PF that
> would arise from the access is injected to the guest, regardless of
> whether there might also be gfn -> mfn errors that would otherwise
> prevent the #PF from being detected.

Yes.

>> @@ -600,27 +614,28 @@ static void *hvmemul_map_linear_addr(
>>              goto out;
>>  
>>          case HVMTRANS_bad_gfn_to_mfn:
>> -            err = NULL;
>> -            goto out;
>> +            err = update_map_err(err, NULL);
>> +            continue;
>>  
>>          case HVMTRANS_gfn_paged_out:
>>          case HVMTRANS_gfn_shared:
>> -            err = ERR_PTR(~X86EMUL_RETRY);
>> -            goto out;
>> +            err = update_map_err(err, ERR_PTR(~X86EMUL_RETRY));
>> +            continue;
>>  
>>          default:
>> -            goto unhandleable;
>> +            err = update_map_err(err, ERR_PTR(~X86EMUL_UNHANDLEABLE));
>> +            continue;
>>          }
>>  
>>          *mfn++ = page_to_mfn(page);
> 
> I have to admit it find it weird that since now we don't exit the loop
> when HVMTRANS_bad_gfn_to_mfn is returned, the item at mfn[0] might
> point to the gfn -> mfn translation for the second half of the access.
> AFAICT that would happen if the first half of the access fails to
> translate with an error !HVMTRANS_bad_linear_to_gfn and the second
> half is successful.
> 
> I guess it doesn't matter much, because the vmap below will be
> skipped, might still be worth to add a comment.

I could add one, but as you say it doesn't matter much, plus - I don't
see a good place where such a comment would go.

> In fact, if the first translation fails the following ones could use
> the cheaper paging_gva_to_gfn(), as we no longer care to get the
> underlying page, and just need to figure out whether the access would
> trigger a #PF?

That would be an option, yes, at the expense of (slightly) more
complicated logic. Of course going that route would then also address
your mfn[0] remark above, without the need for any comment.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.