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

Re: [PATCH] x86/PAT: have pat_enabled() properly reflect state when running on e.g. Xen


  • To: Borislav Petkov <bp@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 7 Jul 2022 08:38: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=k8l4Nf8fQ67bEwIAO+a1iTiSd6Jzq1VNu3+xuHiRqxA=; b=SIZicQKRhmS7mZw5aZgll9PXqIgDPwdvC8FnfULNzebu5w69jc5ZUR8RGIbGCUAPBTFKODPd69mA7UHm7p5VexzQREKY+aBjBvB0TEmKu0l78igY9h+SfkXgOfZnL+C+emG/1OdxVF7CYtaP+PMQQl3ccjWibvjfUg4dBVCEfzNXzr+9Qfutt8DHZ1zR1xwwAa3l3nlvmedPNQtAQxR4pxm3McPkIO9EE2+UNpSOgj+ySljwEXf4YSRqKEtBllGKbH6qKS2Ub/mdXGUKbME5MJHNMtpf0fBMnCPWCSrSVH7yX5bDEej+2j2gaA4QqFAfzRCCx6HZwy3b0icDuVto3g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BVqooPY1la/VXv31gWYrZTHxT8fwRCF6ukm0HF12mrMRN4beZPj7Qs+X4zmJceUJ7VPFzwVedo6nWUXix6YhLVhNUlDcYoQ7IT2DfU97ekbvzqRCksIGQpCex1pi6xQEgvUbfZg/0K3jdXA4NpxutM8t2HIfc3ZlfDzKuvlLSNhWebacfKdcb+WZvmnxht8U1GUkqmXBHcsVGZdLcyfFuOaoLPvNPIjkVGsh1twXaVYaeGdFkQF8u0/xo7vYfsTtHGHecMdCPXbUFH/an3lenqvP31PTlyNOXKR3QGzPN4L7GrTYpHQuhvU38dDeZBMzuL4XuxCfTKYp2JYLKtt1iA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Lutomirski <luto@xxxxxxxxxx>, "dave.hansen@xxxxxxxxxxxxxxx" <dave.hansen@xxxxxxxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, lkml <linux-kernel@xxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 07 Jul 2022 06:39:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.07.2022 19:01, Borislav Petkov wrote:
> On Wed, Jul 06, 2022 at 08:17:41AM +0200, Jan Beulich wrote:
>> Sure, but that alone won't help.
> 
> Well, the MTRR code looks at X86_FEATURE_MTRR. If Xen doesn't expose the
> MTRRs, then that bit should be clear in the CPUID the guest sees.
> 
> So in that case, you could test X86_FEATURE_XENPV at the end of
> mtrr_bp_init() and not disable PAT if running as a PV guest. Would that
> work?
> 
>> There's a beneficial side effect of running through pat_disable():
>> That way pat_init() will bail right away. Without that I'd need to
>> further special case things there (as under Xen/PV PAT must not be
>> written, only read)
> 
> We have wrmsr_safe for that.

Well, right now the pvops hook for Xen swallows #GP anyway (wrongly
so imo, but any of my earlier pointing out of that has been left
unheard, despite even the code comments there saying "It may be worth
changing that"). The point is therefore that after writing PAT, it
would need reading back. In which case it feels (slightly) more clean
to me to avoid the write attempt in the first place, when we know
it's not going to work.

>> Any decent hypervisor will allow overriding CPUID, so in principle
>> I'd expect any to permit disabling MTRR to leave a guest to use
>> the (more modern and less cumbersome) PAT alone.
> 
> So I'm being told that it would be generally beneficial for all kinds of
> virtualization solutions to be able to support PAT only, without MTRRs
> so it would be interesting to see how ugly it would become to decouple
> PAT from MTRRs in Linux...

If I may ask - doesn't this mean this patch, in its current shape, is
already a (small) step in that direction? In any event what you say
doesn't sound to me like a viable (backportable) route to addressing
the regression at hand.

Jan



 


Rackspace

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