All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>, Wei Liu <wl@xen.org>,
	Jan Beulich <JBeulich@suse.com>
Subject: Re: [Xen-devel] [PATCH 6/6] x86/suspend: Drop save_rest_processor_state() completely
Date: Tue, 17 Dec 2019 13:38:14 +0100	[thread overview]
Message-ID: <20191217123814.GZ11756@Air-de-Roger> (raw)
In-Reply-To: <20191213190436.24475-7-andrew.cooper3@citrix.com>

On Fri, Dec 13, 2019 at 07:04:36PM +0000, Andrew Cooper wrote:
> Construct the system linkage MSRs using percpu_traps_init(), brining the S3
> path in line with the BSP/AP path.  Restore xcr0 from the per-cpu shadow copy.
> 
> The FS/GS base values are unused in Xen context, and will be loaded
> appropriately by the next vcpu context switch.
> 
> Trim the include list substantially, as most are unused.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wl@xen.org>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> ---
>  xen/arch/x86/acpi/suspend.c     | 54 +++--------------------------------------
>  xen/arch/x86/acpi/wakeup_prot.S |  2 --
>  2 files changed, 3 insertions(+), 53 deletions(-)
> 
> diff --git a/xen/arch/x86/acpi/suspend.c b/xen/arch/x86/acpi/suspend.c
> index 32d0f71ffd..629d117965 100644
> --- a/xen/arch/x86/acpi/suspend.c
> +++ b/xen/arch/x86/acpi/suspend.c
> @@ -4,40 +4,8 @@
>   *  Copyright (c) 2001 Patrick Mochel <mochel@osdl.org>
>   */
>  
> -#include <xen/acpi.h>
> -#include <xen/smp.h>
> -#include <asm/processor.h>
> -#include <asm/msr.h>
> -#include <asm/debugreg.h>
> -#include <asm/hvm/hvm.h>
> -#include <asm/hvm/support.h>
> -#include <asm/i387.h>
> +#include <asm/system.h>
>  #include <asm/xstate.h>
> -#include <xen/hypercall.h>
> -
> -static unsigned long saved_lstar, saved_cstar;
> -static unsigned long saved_sysenter_esp, saved_sysenter_eip;
> -static unsigned long saved_fs_base, saved_gs_base, saved_kernel_gs_base;
> -static uint64_t saved_xcr0;
> -
> -void save_rest_processor_state(void)
> -{
> -    saved_fs_base = rdfsbase();
> -    saved_gs_base = rdgsbase();
> -    rdmsrl(MSR_SHADOW_GS_BASE, saved_kernel_gs_base);
> -    rdmsrl(MSR_CSTAR, saved_cstar);
> -    rdmsrl(MSR_LSTAR, saved_lstar);
> -
> -    if ( cpu_has_sep )
> -    {
> -        rdmsrl(MSR_IA32_SYSENTER_ESP, saved_sysenter_esp);
> -        rdmsrl(MSR_IA32_SYSENTER_EIP, saved_sysenter_eip);
> -    }
> -
> -    if ( cpu_has_xsave )
> -        saved_xcr0 = get_xcr0();
> -}
> -
>  
>  void restore_rest_processor_state(void)
>  {
> @@ -46,25 +14,9 @@ void restore_rest_processor_state(void)
>      /* Restore full CR4 (inc MCE) now that the IDT is in place. */
>      write_cr4(mmu_cr4_features);
>  
> -    /* Recover syscall MSRs */
> -    wrmsrl(MSR_LSTAR, saved_lstar);
> -    wrmsrl(MSR_CSTAR, saved_cstar);
> -    wrmsrl(MSR_STAR, XEN_MSR_STAR);
> -    wrmsrl(MSR_SYSCALL_MASK, XEN_SYSCALL_MASK);
> -
> -    wrfsbase(saved_fs_base);
> -    wrgsbase(saved_gs_base);
> -    wrmsrl(MSR_SHADOW_GS_BASE, saved_kernel_gs_base);
> -
> -    if ( cpu_has_sep )
> -    {
> -        /* Recover sysenter MSRs */
> -        wrmsrl(MSR_IA32_SYSENTER_ESP, saved_sysenter_esp);
> -        wrmsrl(MSR_IA32_SYSENTER_EIP, saved_sysenter_eip);
> -        wrmsr(MSR_IA32_SYSENTER_CS, __HYPERVISOR_CS, 0);
> -    }
> +    percpu_traps_init();
>  
> -    if ( cpu_has_xsave && !set_xcr0(saved_xcr0) )
> +    if ( cpu_has_xsave && !set_xcr0(get_xcr0()) )
>          BUG();
>  
>      wrmsrl(MSR_IA32_CR_PAT, XEN_MSR_PAT);

Given what this functions does after this change, would it be feasible
to place such calls directly in enter_state?

AFAICT there's already some restoring done there anyway.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-12-17 12:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13 19:04 [Xen-devel] [PATCH 0/6] x86/suspend: State cleanup Andrew Cooper
2019-12-13 19:04 ` [Xen-devel] [PATCH 1/6] x86/suspend: Clarify and improve the behaviour of do_suspend_lowlevel() Andrew Cooper
2019-12-16 17:24   ` Roger Pau Monné
2019-12-13 19:04 ` [Xen-devel] [PATCH 2/6] x86/suspend: Don't bother saving %cr3, %ss or flags Andrew Cooper
2019-12-17 11:52   ` Roger Pau Monné
2019-12-17 12:06     ` Andrew Cooper
2019-12-17 12:18       ` Roger Pau Monné
2019-12-17 12:26         ` Andrew Cooper
2019-12-17 15:10           ` Roger Pau Monné
2019-12-13 19:04 ` [Xen-devel] [PATCH 3/6] x86/suspend: Don't save unnecessary GPRs Andrew Cooper
2019-12-17 12:04   ` Roger Pau Monné
2019-12-17 12:10     ` Andrew Cooper
2019-12-17 12:13       ` Roger Pau Monné
2019-12-13 19:04 ` [Xen-devel] [PATCH 4/6] x86/suspend: Restore cr4 later during resume Andrew Cooper
2019-12-17 12:12   ` Roger Pau Monné
2019-12-13 19:04 ` [Xen-devel] [PATCH 5/6] x86/suspend: Expand macros in wakeup_prot.S Andrew Cooper
2019-12-17 12:32   ` Roger Pau Monné
2019-12-13 19:04 ` [Xen-devel] [PATCH 6/6] x86/suspend: Drop save_rest_processor_state() completely Andrew Cooper
2019-12-17 12:38   ` Roger Pau Monné [this message]
2019-12-17 20:37     ` Andrew Cooper
2019-12-17 16:17 ` [Xen-devel] [PATCH 0/6] x86/suspend: State cleanup Jan Beulich
2019-12-17 16:33   ` Andrew Cooper
2019-12-17 16:39     ` Jan Beulich
2019-12-18 11:39       ` Andrew Cooper
2019-12-18 11:52         ` 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=20191217123814.GZ11756@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@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.