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

Re: [PATCH v2 1/3] xen/pv: allow pmu msr accesses to cause GP


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 4 Oct 2022 12:58:57 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; 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=C5U+h09P+uAMkkShW0Lxk3PudcKWH0c//pqKniczqKU=; b=DBH8DRnENdJzsyPn4wHG3aZumvTX8KiSjiDnD3C0hbBvB4+e9xfEScxBJR5pfjeTT6frQQH/clFO8K5DZhWVqHhQ1GfP0jBUKo4LDMB/2EfBDGoZxPtr8bSuaqZeDi2y1xw1TjHcHdIAy7WOK+PZBsqFeUCN9sNiby+TGLTvollQoDtV3asJSeGnlHk3jueuYJbyoi5prPYABYdtbXqaLbinW28LD9lfWf5DKx8xZYEPYaySWoZ5yOGmFR5brCKnwTUWAunZyb71VUoiIw+ORqHFajfmkLl/xQDhkSh6YobnPoUjQmoMSFklnh1QSLbIFTfYLG4XjbFy1D71Iz6vsA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lm7UEi5AOV0xNu1d1eHUbkgN2p5sYUsNZ5D3hGf+138eQ8vKeARfJBu8OWygoOP1QDU7Qrdkf0Cjvt0yXJvSxUj/FYI/eJXvI3QqiYvMR1H7GEiJdkHpDmwDdc2YsWV2pYnEyu+4kehp2v1y+1h/tMGyPWl8jW3g/2sT1Em+D0xnewInRDzGRnCDQ+zyhos7XSx4EyJzsa4/whBAuD1YyZPR86boH+q9QRn7TtDn+eqQDXYfkqKInOBUgQ7x0lMA+to9pHGnWX092rZmzk+UZzFO1yGqHfWeK8d1pV6vPQM8eM0Ma8w6XvRqUahTpbCleJJ/JiHyORFWRq0mgMmeZw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx
  • Delivery-date: Tue, 04 Oct 2022 10:59:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 04.10.2022 10:43, Juergen Gross wrote:
> Today pmu_msr_read() and pmu_msr_write() fall back to the safe variants
> of read/write MSR in case the MSR access isn't emulated via Xen. Allow
> the caller to select the potentially faulting variant by passing NULL
> for the error pointer.
> 
> Restructure the code to make it more readable.
> 
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>

I think the title (and to some degree also the description) is misleading:
The property we care about here isn't whether an MSR access would raise
#GP (we can't control that), but whether that #GP would be recovered from.

> --- a/arch/x86/xen/pmu.c
> +++ b/arch/x86/xen/pmu.c
> @@ -131,6 +131,9 @@ static inline uint32_t get_fam15h_addr(u32 addr)
>  
>  static inline bool is_amd_pmu_msr(unsigned int msr)
>  {
> +     if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
> +             return false;

I understand this and ...

> @@ -144,6 +147,9 @@ static int is_intel_pmu_msr(u32 msr_index, int *type, int 
> *index)
>  {
>       u32 msr_index_pmc;
>  
> +     if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
> +             return false;

... this matches prior behavior, but may I suggest that while moving
these here you at least accompany them by a comment clarifying that
these aren't really correct? We'd come closer if is_amd_pmu_msr()
accepted AMD and Hygon, while is_intel_pmu_msr() may want to accept
Intel and Centaur (but I understand this would be largely orthogonal,
hence the suggestion towards comments). In the hypervisor we kind of
also support Shanghai, but I wonder whether we wouldn't better rip
out that code as unmaintained.

Jan



 


Rackspace

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