All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/amd: do not expose HWCR.TscFreqSel to guests
@ 2023-09-12 16:23 Roger Pau Monne
  2023-09-12 16:35 ` Andrew Cooper
  2023-09-13  6:14 ` Jan Beulich
  0 siblings, 2 replies; 18+ messages in thread
From: Roger Pau Monne @ 2023-09-12 16:23 UTC (permalink / raw)
  To: xen-devel; +Cc: Roger Pau Monne, Jan Beulich, Andrew Cooper, Wei Liu

OpenBSD will attempt to unconditionally access PSTATE0 if HWCR.TscFreqSel is
set, and will also attempt to unconditionally access HWCR if the TSC is
reported as Invariant.

The reasoning for exposing HWCR.TscFreqSel was to avoid Linux from printing a
(bogus) warning message, but doing so at the cost of OpenBSD not booting is not
a suitable solution.

In order to fix expose an empty HWCR.

Fixes: 14b95b3b8546 ('x86/AMD: expose HWCR.TscFreqSel to guests')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Not sure whether we want to expose something when is_cpufreq_controller() is
true, seeing as there's a special wrmsr handler for the same MSR in that case.
Likely should be done for PV only, but also likely quite bogus.

Missing reported by as the issue came from the QubesOS tracker.
---
 xen/arch/x86/msr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 3f0450259cdf..964d500ff8a1 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -240,8 +240,12 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
     case MSR_K8_HWCR:
         if ( !(cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
             goto gp_fault;
-        *val = get_cpu_family(cp->basic.raw_fms, NULL, NULL) >= 0x10
-               ? K8_HWCR_TSC_FREQ_SEL : 0;
+        /*
+         * OpenBSD 7.3 accesses HWCR unconditionally if the TSC is reported as
+         * Invariant.  Do not set TSC_FREQ_SEL as that would trigger OpenBSD to
+         * also poke at PSTATE0.
+         */
+        *val = 0;
         break;
 
     case MSR_VIRT_SPEC_CTRL:
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-09-13 20:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-12 16:23 [PATCH] x86/amd: do not expose HWCR.TscFreqSel to guests Roger Pau Monne
2023-09-12 16:35 ` Andrew Cooper
2023-09-12 16:36   ` Andrew Cooper
2023-09-13  8:08     ` Roger Pau Monné
2023-09-13 10:11       ` Andrew Cooper
2023-09-13  6:18   ` Jan Beulich
2023-09-13  8:50     ` Roger Pau Monné
2023-09-13 11:02     ` [Xen PATCH] " Andrew Cooper
2023-09-13 13:37       ` Jan Beulich
2023-09-13 20:31       ` Thomas Gleixner
2023-09-13  7:50   ` [PATCH] " Roger Pau Monné
2023-09-13 10:50     ` Andrew Cooper
2023-09-13 13:27       ` Jan Beulich
2023-09-13  6:14 ` Jan Beulich
2023-09-13  8:20   ` Roger Pau Monné
2023-09-13  8:35     ` Jan Beulich
2023-09-13  9:16       ` Roger Pau Monné
2023-09-13  9:40         ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.