Message ID | 20220128171804.569796-24-brijesh.singh@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add AMD Secure Nested Paging (SEV-SNP) Guest Support | expand |
On Fri, Jan 28, 2022 at 11:17:44AM -0600, Brijesh Singh wrote: > From: Michael Roth <michael.roth@amd.com> > > Determining which CPUID leafs have significant ECX/index values is > also needed by guest kernel code when doing SEV-SNP-validated CPUID > lookups. Move this to common code to keep future updates in sync. > > Reviewed-by: Venu Busireddy <venu.busireddy@oracle.com> > Signed-off-by: Michael Roth <michael.roth@amd.com> > Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> > --- > arch/x86/include/asm/cpuid.h | 38 ++++++++++++++++++++++++++++++++++++ > arch/x86/kvm/cpuid.c | 19 ++---------------- > 2 files changed, 40 insertions(+), 17 deletions(-) > create mode 100644 arch/x86/include/asm/cpuid.h > > diff --git a/arch/x86/include/asm/cpuid.h b/arch/x86/include/asm/cpuid.h > new file mode 100644 > index 000000000000..00408aded67c > --- /dev/null > +++ b/arch/x86/include/asm/cpuid.h > @@ -0,0 +1,38 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Kernel-based Virtual Machine driver for Linux cpuid support routines > + * > + * derived from arch/x86/kvm/x86.c > + * derived from arch/x86/kvm/cpuid.c > + * > + * Copyright 2011 Red Hat, Inc. and/or its affiliates. > + * Copyright IBM Corporation, 2008 > + */ I have no clue what you're trying to achieve by copying the copyright of the file this comes from. As dhansen properly points out, those lines in that function come from other folks/companies too so why even bother with this? git history holds the correct and full copyright anyway...
On Thu, Feb 03, 2022 at 04:16:33PM +0100, Borislav Petkov wrote: > On Fri, Jan 28, 2022 at 11:17:44AM -0600, Brijesh Singh wrote: > > From: Michael Roth <michael.roth@amd.com> > > > > Determining which CPUID leafs have significant ECX/index values is > > also needed by guest kernel code when doing SEV-SNP-validated CPUID > > lookups. Move this to common code to keep future updates in sync. > > > > Reviewed-by: Venu Busireddy <venu.busireddy@oracle.com> > > Signed-off-by: Michael Roth <michael.roth@amd.com> > > Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> > > --- > > arch/x86/include/asm/cpuid.h | 38 ++++++++++++++++++++++++++++++++++++ > > arch/x86/kvm/cpuid.c | 19 ++---------------- > > 2 files changed, 40 insertions(+), 17 deletions(-) > > create mode 100644 arch/x86/include/asm/cpuid.h > > > > diff --git a/arch/x86/include/asm/cpuid.h b/arch/x86/include/asm/cpuid.h > > new file mode 100644 > > index 000000000000..00408aded67c > > --- /dev/null > > +++ b/arch/x86/include/asm/cpuid.h > > @@ -0,0 +1,38 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +/* > > + * Kernel-based Virtual Machine driver for Linux cpuid support routines > > + * > > + * derived from arch/x86/kvm/x86.c > > + * derived from arch/x86/kvm/cpuid.c > > + * > > + * Copyright 2011 Red Hat, Inc. and/or its affiliates. > > + * Copyright IBM Corporation, 2008 > > + */ > > I have no clue what you're trying to achieve by copying the copyright of > the file this comes from. As dhansen properly points out, those lines > in that function come from other folks/companies too so why even bother > with this? I think Dave's main concern was that I'd added an AMD copyright banner to a new file that was mostly derived from acpi.c. I thought we had some agreement on simply adopting the file-wide copyright banner of whatever source file the new one was derived from, since dropping an existing copyright seemed similarly in bad taste, but if it's sufficient to lean on git for getting a more accurate picture of copyright sources then that sounds good to me and I'll adopt that for the next spin if there are no objections. https://lore.kernel.org/linux-efi/16afaa00-06a9-dc58-6c59-3d1dfb819009@amd.com/T/#m88a765b6090ec794872f73bf0ee6642fd39db947 (In the case of acpi.c it happened to not have a file-wide copyright banner so things were a little more straightforward for the acpi.c->efi.c movement) > > git history holds the correct and full copyright anyway... > > -- > Regards/Gruss, > Boris. > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeople.kernel.org%2Ftglx%2Fnotes-about-netiquette&data=04%7C01%7CMichael.Roth%40amd.com%7C189a90d4aa3e459f7d7908d9e7282f9c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637794982059320697%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=T95Les9sx71RFXYAImDag9%2FclmImsnjMbzPkOvIsbbY%3D&reserved=0
On Thu, Feb 03, 2022 at 10:44:43AM -0600, Michael Roth wrote: > I think Dave's main concern was that I'd added an AMD copyright banner > to a new file that was mostly derived from acpi.c. I thought we had some > agreement on simply adopting the file-wide copyright banner of whatever > source file the new one was derived from, since dropping an existing > copyright seemed similarly in bad taste,... Well, I think simply saying where this function was carved out from: arch/x86/kvm/cpuid.c is good enough. If someone is so much interested in a copyright, someone can read that file's copyright. Especially since that copyright line in the original file is not telling you a whole lot about who are all copyright owners. And before we delve into lawyer-land, let's simply point to where we got this from and be done with it. Thx.
diff --git a/arch/x86/include/asm/cpuid.h b/arch/x86/include/asm/cpuid.h new file mode 100644 index 000000000000..00408aded67c --- /dev/null +++ b/arch/x86/include/asm/cpuid.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Kernel-based Virtual Machine driver for Linux cpuid support routines + * + * derived from arch/x86/kvm/x86.c + * derived from arch/x86/kvm/cpuid.c + * + * Copyright 2011 Red Hat, Inc. and/or its affiliates. + * Copyright IBM Corporation, 2008 + */ + +#ifndef _ASM_X86_CPUID_H +#define _ASM_X86_CPUID_H + +static __always_inline bool cpuid_function_is_indexed(u32 function) +{ + switch (function) { + case 4: + case 7: + case 0xb: + case 0xd: + case 0xf: + case 0x10: + case 0x12: + case 0x14: + case 0x17: + case 0x18: + case 0x1d: + case 0x1e: + case 0x1f: + case 0x8000001d: + return true; + } + + return false; +} + +#endif /* _ASM_X86_CPUID_H */ diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 3902c28fb6cb..3458dd3272a0 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -19,6 +19,7 @@ #include <asm/user.h> #include <asm/fpu/xstate.h> #include <asm/sgx.h> +#include <asm/cpuid.h> #include "cpuid.h" #include "lapic.h" #include "mmu.h" @@ -699,24 +700,8 @@ static struct kvm_cpuid_entry2 *do_host_cpuid(struct kvm_cpuid_array *array, cpuid_count(entry->function, entry->index, &entry->eax, &entry->ebx, &entry->ecx, &entry->edx); - switch (function) { - case 4: - case 7: - case 0xb: - case 0xd: - case 0xf: - case 0x10: - case 0x12: - case 0x14: - case 0x17: - case 0x18: - case 0x1d: - case 0x1e: - case 0x1f: - case 0x8000001d: + if (cpuid_function_is_indexed(function)) entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX; - break; - } return entry; }