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

Re: [PATCH 3/5] x86/PV: restrict guest-induced WBINVD (or alike) to cache writeback


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 20 Apr 2023 11:08:44 +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=JI5EVmmDpYm8IlsuJKdADFEyaspx7x1QIzgvOy/1n0Y=; b=gTAzaavRu1mMVc12gkYys5OE+bEcGIUQ2M0ksiwz2I56GcQWj+8yavRQ8r8NtkGpTva7+2f8RHotspUSTnWUlYBZfA5+DL/hq/MQwQzHTsS09NWg9u3rtehu4QABTU2Pt/kme62g2bfupC85jgX3qn41aSUA4g7rVz33y3QXysz/4dI0Cqb3S7a1Bam8eQREuM8UtSntSOW8/vHzbEJOiLkZAEiCrj8yNzAeMUqMG1uT1+IhKpo3LviSA/MPpUgaGxCUMdtOWe80tYzDCLYm6/hL5FzsVRYh9IPgJsT44Ih1w7pti+5+5W/QLhMlT3Iy8YxjCHId+bkEDA8DcCCbVw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F5STbLhpl93ji5LFNjwFmlxY586XDp9rdhXynlec3viF+kJq5NvVO3jsRWHyS73Or+Md9MWHUHjukup4eYhA0sJYffQ/INeecrNu8p6xs/2GxF13MBK/Yzh9fcRUlST896UmiLOvHFEGMyrLWZ93vg2i+8foZ4sO8T9DENzQFqIGIIOn4clA3x2FFpl9HjPwx+pz4ljCUqVdxo9N4jtVnZnqk8BU4HFEd1usCxTFjz2dDVEVHstHTzk6j82TizILj8Ipb4kiQKozE4AilT6gVjEKMAemyqe02quHwodDbH2AbB1EqIN94j2W/Y1EOtVomvw3vNK1ikFOlIRorN2m9w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 20 Apr 2023 09:09:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 19.04.2023 22:10, Andrew Cooper wrote:
> On 19/04/2023 11:45 am, Jan Beulich wrote:
>> --- a/xen/arch/x86/mm.c
>> +++ b/xen/arch/x86/mm.c
>> @@ -3772,7 +3772,7 @@ long do_mmuext_op(
>>              else if ( unlikely(!cache_flush_permitted(currd)) )
>>                  rc = -EACCES;
>>              else
>> -                wbinvd();
>> +                wbnoinvd();
>>              break;
> 
> It occurs to me that this is fundamentally broken.
> 
> The guest is not in any position to know (or control) whether it gets
> rescheduled elsewhere between now and it logically continuing execution.
> 
> So if there is actually any cache maintenance to do, it can't be a
> WB{...} of any form on just this CPU alone.

Aren't you merely confirming the respective paragraph in the cover letter
here? (The implication would be that at least the data added in the last
patch wants to be guest-type-independent, so that it can be re-used for
PV, even if maybe not in the same patch.)

>> --- a/xen/include/public/arch-x86/cpufeatureset.h
>> +++ b/xen/include/public/arch-x86/cpufeatureset.h
>> @@ -238,7 +238,7 @@ XEN_CPUFEATURE(EFRO,          7*32+10) /
>>  /* AMD-defined CPU features, CPUID level 0x80000008.ebx, word 8 */
>>  XEN_CPUFEATURE(CLZERO,        8*32+ 0) /*A  CLZERO instruction */
>>  XEN_CPUFEATURE(RSTR_FP_ERR_PTRS, 8*32+ 2) /*A  (F)X{SAVE,RSTOR} always 
>> saves/restores FPU Error pointers */
>> -XEN_CPUFEATURE(WBNOINVD,      8*32+ 9) /*S  WBNOINVD instruction */
>> +XEN_CPUFEATURE(WBNOINVD,      8*32+ 9) /*A  WBNOINVD instruction */
> 
> Given that PV guests do have several real hypercalls for doing this, I'm
> not particularly inclined to let them do it via an emulated path,
> however easy it might be at a technical level.
> 
> I doubt anything good can come from it.

We permit use of WBINVD; it looks inconsistent to me to not also permit
WBNOINVD then. Furthermore exposing the feature then can serve as a
(better) hint that behind the scenes we actually carry out the mmuext
ops as write-back. not evict.

Jan



 


Rackspace

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