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

Re: [PATCH] x86/hvm: Drop get_shadow_gs_base() hook and use hvm_get_reg()


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 21 Jan 2022 15:06:27 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=mukw2TsNT5gvUSY3f/x3PNsjn46v23w76n+ZGVEwkKY=; b=aT7sPHNkFJ/h+TM3mhAVoIu6yQOrDGkioLlKqYc9a0qK8kYaKdHrNst95uFLqevbCXcj3/vHvBBdMFoEzXHZwCc2kkRGuWRqkUw4X4dWJWR4tvrJAVlV2Z0+JZAe7rWHUjn9RikmH/wZFkn496zw7EjFfEi8ckgjNPKEXt0VtVSB40hQ85ORZbdYUq0Ds8ovI6vziQ9mFTnOX0sMTRVV2KwKA0ROYvsk/8arm0g8cfmGrPHvCU5CWgKu/2rcM4cLvfHanU3DW5CxK7KkLvkckKiMFzqLIw1l25/wtuuffygs3G48NgW7QMTIkhbZcEW3vVKvkkNfgDOZEi3iJmUxug==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iscIq0bFwVkXQPlspdIyW0tiIICFGkB2HidtKA+eNDMLGV94VIoMLq+kdgylRSxbpdTwl1Ic9OLm+o4zp0GDVbfD1heSZSkFC8+4Xn+3XMt/PnxPoYinpn/vlrRNuRpqD7KkQLeg6+4V7FHs8Nuh9mvOS8CNiq7mimMNVJ05HYrw/Fma/RuXSzJFyXmE6BsoblUiiavRUSHfHqUTyo0CLd8di9/8rQqxD/t25kclRCuaRzu0KNxuuXbR2sM1LekBsMUCINFv7r0+cb10aJ/5tlVAR2jEnbBLjPco/RLTWNBb7uo47nujkDdMPRzOQnEVe6itDq24/wfo8eL7DxIVmw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 21 Jan 2022 14:06:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21.01.2022 12:22, Andrew Cooper wrote:
> This is a trivial accessor for an MSR, so use hvm_get_reg() rather than a
> dedicated hook.  In arch_get_info_guest(), rework the logic to read GS_SHADOW
> only once.
> 
> get_hvm_registers() is called on current, meaning that diagnostics print a
> stale GS_SHADOW from the previous vcpu context switch.  Adjust both
> implementations to obtain the correct value.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Just one minor request for consideration at the end.

> If we care to backport the bugfix aspect, a far less invasive option would be
> to read MSR_SHADOW_GS_BASE directly.
> 
> The only case where that goes wrong is when vmcb->kerngsbase has been modified
> and is pending a VMLOAD.  I'm fairly sure this can only occur when we need
> vcpu diagnostics, after an emulated write of MSR_SHADOW_GS_BASE.

Hmm. Maybe best to leave alone in stable trees?

> @@ -2417,6 +2413,15 @@ static uint64_t vmx_get_reg(struct vcpu *v, unsigned 
> int reg)
>              domain_crash(d);
>          }
>          return val;
> +
> +    case MSR_SHADOW_GS_BASE:
> +        if ( v == curr )
> +        {
> +            rdmsrl(MSR_SHADOW_GS_BASE, val);
> +            return val;
> +        }
> +        else
> +            return v->arch.hvm.vmx.shadow_gs;
>      }

I think it wasn't too long ago that I saw you ask for an "else" like
this one to be dropped (in someone else's patch). May I ask that you
consider doing so here, perhaps going straight to the more compact

    case MSR_SHADOW_GS_BASE:
        if ( v != curr )
            return v->arch.hvm.vmx.shadow_gs;
        rdmsrl(MSR_SHADOW_GS_BASE, val);
        return val;

?

Actually, as I notice only now: Would you mind making "curr" here and
in the VMX equivalent pointer-to-const?

Jan




 


Rackspace

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