All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>
Subject: [PATCH v2 2/2][4.15] x86/AMD: expose HWCR.TscFreqSel to guests
Date: Fri, 5 Mar 2021 10:50:54 +0100	[thread overview]
Message-ID: <c91b190a-aaa1-d3b8-10eb-d8da7ad1f834@suse.com> (raw)
In-Reply-To: <f5f17207-b601-2909-8a5c-55276e734272@suse.com>

Linux has been warning ("firmware bug") about this bit being clear for a
long time. While writable in older hardware it has been readonly on more
than just most recent hardware. For simplicitly report it always set (if
anything we may want to log the issue ourselves if it turns out to be
clear on older hardware).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: New.
---
There are likely more bits worthwhile to expose, but for about every one
of them there would be the risk of a lengthy discussion, as there are
clear downsides to exposing such information, the more that it would be
tbd whether the hardware values should be surfaced, and if so what
should happen when the guest gets migrated.

The main risk with making the read not fault here is that guests might
imply they can also write this MSR then.

--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -315,6 +315,12 @@ int guest_rdmsr(struct vcpu *v, uint32_t
         *val = msrs->tsc_aux;
         break;
 
+    case MSR_K8_HWCR:
+        if ( !(cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
+            goto gp_fault;
+        *val = K8_HWCR_TSC_FREQ_SEL;
+        break;
+
     case MSR_AMD64_DE_CFG:
         if ( !(cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
             goto gp_fault;
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -287,6 +287,8 @@
 
 #define MSR_K7_HWCR			0xc0010015
 #define MSR_K8_HWCR			0xc0010015
+#define K8_HWCR_TSC_FREQ_SEL		(1ULL << 24)
+
 #define MSR_K7_FID_VID_CTL		0xc0010041
 #define MSR_K7_FID_VID_STATUS		0xc0010042
 #define MSR_K8_PSTATE_LIMIT		0xc0010061



  parent reply	other threads:[~2021-03-05  9:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05  9:43 [PATCH v2 0/2][4.15] x86: guest MSR access handling tweaks Jan Beulich
2021-03-05  9:50 ` [PATCH v2 1/2][4.15] x86/PV: conditionally avoid raising #GP for early guest MSR reads Jan Beulich
2021-03-08  8:56   ` Roger Pau Monné
2021-03-08  9:33     ` Jan Beulich
2021-03-08 12:11       ` Roger Pau Monné
2021-03-08 13:49         ` Jan Beulich
2021-03-09 10:17           ` Roger Pau Monné
2021-03-09 11:16             ` Jan Beulich
2021-03-09 13:37               ` Roger Pau Monné
2021-03-09 14:50                 ` Jan Beulich
2021-03-09 15:19                   ` Roger Pau Monné
2021-03-09 16:07                     ` Jan Beulich
2021-03-05  9:50 ` Jan Beulich [this message]
2021-03-08 11:37   ` [PATCH v2 2/2][4.15] x86/AMD: expose HWCR.TscFreqSel to guests Roger Pau Monné
2021-03-08 11:47     ` Jan Beulich
2021-03-08 12:29       ` Roger Pau Monné
2021-03-08 13:42         ` Jan Beulich
2021-03-08 12:41   ` Andrew Cooper
2021-03-08 13:23     ` Roger Pau Monné
2021-03-08 13:24     ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c91b190a-aaa1-d3b8-10eb-d8da7ad1f834@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.