linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Li, Xin3" <xin3.li@intel.com>
To: "Gross, Jurgen" <jgross@suse.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"brgerst@gmail.com" <brgerst@gmail.com>,
	"Bae, Chang Seok" <chang.seok.bae@intel.com>
Subject: RE: [PATCH v4 5/5] x86/gsseg: use the LKGS instruction if available for load_gs_index()
Date: Thu, 20 Oct 2022 05:58:12 +0000	[thread overview]
Message-ID: <BN6PR1101MB21614EE46D700C24E7D77E8FA82A9@BN6PR1101MB2161.namprd11.prod.outlook.com> (raw)
In-Reply-To: <7bbc19c8-3494-1770-d186-ce5a92d511aa@suse.com>

> On 19.10.22 19:45, Li, Xin3 wrote:
> >>> +static inline void __init lkgs_init(void) { #ifdef
> >>> +CONFIG_PARAVIRT_XXL #ifdef CONFIG_X86_64
> >>> +	if (cpu_feature_enabled(X86_FEATURE_LKGS))
> >>> +		pv_ops.cpu.load_gs_index = native_lkgs;
> >>
> >> For this to work correctly when running as a Xen PV guest, you need
> >> to add
> >>
> >> 	setup_clear_cpu_cap(X86_FEATURE_LKGS);
> >>
> >> to xen_init_capabilities() in arch/x86/xen/enlighten_pv.c, as
> >> otherwise the Xen specific .load_gs_index vector will be overwritten.
> >
> > Yeah, we definitely should add it to disable LKGS in a Xen PV guest.
> >
> > So does it mean that the Xen PV uses a black list during feature detection?
> > If yes then new features are often required to be masked with an
> > explicit call to setup_clear_cpu_cap.
> >
> > Wouldn't a white list be better?
> > Then the job is more just on the Xen PV side, and it can selectively
> > enable a new feature, sometimes with Xen PV specific handling code added.
> 
> This is not how it works. Feature detection is generic code, so we'd need to
> tweak that for switching to a whitelist.
>

Yes, a Xen PV guest is basically a Linux system.  However IIRC, the Xen PV
CPUID is para-virtualized, so it's Xen hypervisor's responsibility to decide
features exposed to a Xen PV guest.  No?

> Additionally most features don't require any Xen PV specific handling. This is
> needed for some paravirtualized privileged operations only. So switching to a
> whitelist would add more effort.
> 

LKGS is allowed only in ring 0, thus only Xen hypervisor could use it.

Xin

> 
> Juergen


  reply	other threads:[~2022-10-20  5:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19  9:50 [PATCH v4 0/5] Enable LKGS instruction Xin Li
2022-10-19  9:50 ` [PATCH v4 1/5] x86/cpufeature: add the cpu feature bit for LKGS Xin Li
2022-10-19  9:50 ` [PATCH v4 2/5] x86/opcode: add the LKGS instruction to x86-opcode-map Xin Li
2022-10-19  9:50 ` [PATCH v4 3/5] x86/gsseg: make asm_load_gs_index() take an u16 Xin Li
2022-10-19  9:50 ` [PATCH v4 4/5] x86/gsseg: move load_gs_index() to its own new header file Xin Li
2022-10-19  9:50 ` [PATCH v4 5/5] x86/gsseg: use the LKGS instruction if available for load_gs_index() Xin Li
2022-10-19 12:16   ` Juergen Gross
2022-10-19 17:45     ` Li, Xin3
2022-10-19 18:01       ` H. Peter Anvin
2022-10-20  4:54         ` Juergen Gross
2022-10-20  6:05           ` Li, Xin3
2022-10-20  4:53       ` Juergen Gross
2022-10-20  5:58         ` Li, Xin3 [this message]
2022-10-20  6:08           ` Juergen Gross
2022-10-20  6:24             ` Li, Xin3
2022-10-19 10:23 [PATCH v4 0/5] x86: Enable LKGS instruction Xin Li
2022-10-19 10:23 ` [PATCH v4 5/5] x86/gsseg: use the LKGS instruction if available for load_gs_index() Xin Li

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=BN6PR1101MB21614EE46D700C24E7D77E8FA82A9@BN6PR1101MB2161.namprd11.prod.outlook.com \
    --to=xin3.li@intel.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).