Message ID | 20221222230458.3828342-2-vannapurve@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp32867wrn; Thu, 22 Dec 2022 15:06:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXt+tAE9yygd6oQQVEdKW2GuF6k7pqL0OxDz9W2CYiuPYOw95dkzmW6s/cvr4eczFy5wT1Ad X-Received: by 2002:a05:6402:2296:b0:46a:96b3:22bf with SMTP id cw22-20020a056402229600b0046a96b322bfmr7093853edb.17.1671750408033; Thu, 22 Dec 2022 15:06:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671750408; cv=none; d=google.com; s=arc-20160816; b=cd8vugYvIfO/kgyonhFwtzj0otXZbWweaScc+a93AS18UZdgfOEmIlSooZIqdJ1UUe Cu9rq2T3vQE6rTZQEgKD1hpUg49R0JYbbcmPeB6k+pC6NFikdejPOVDdUzJpWi6vxLiY 1Gq+ELXk7TUPo2vhomhfo923BjnVmIzY2z3F8ZCcYv4a8/OGBTHAKFUqr385fhMRmkDp G5P5QbAXR/28PWETgIUnmn+UF9JWIK7OTL1EZBcR7CSx9mGfLW8zG+RMGiA2iUP27L8B 3/wGeJwb953a/tcTdYFrgukR6Q+NvuwkObsNwWPfdOC4JbGWFuMafZ2pxQQnTA0Udpor K+Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=QBAw5tj+XZKcsIopd0PuHb+ptawoD6UcsAoOXegakKM=; b=bbI7xrw8XbX6LU40rk97imUYMu355KQ9olZEQnrCC9LJDhKa2/IjMIb/lnoq+iIXu6 k18i9l0pE3bOaZXMWUkqnJpVOpr8peW5HFz0cQ4hGFD2Jbrz3mp4CP+64lOEewpr1usK Ym8TjGf5EByu4bEn3MjxJBOXkX+qvVQ3f664MCFExGhsv10Nh7w7tgZpo1DZjOCugKwq TWKlm80HhqalWlSReyaIdnyviYesTF9BqvGH0DeqVQZ5PBIge3fbvPTt6z7Sk27zfMto GNkTDdXK3xJ6FUdNlaKOs1E02xenZ4YbCuhQajfmF4lmw/st3FqzHOWPp2K9+8CyYYln 045Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FfldrF5j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eh18-20020a0564020f9200b00467570d605esi1358256edb.608.2022.12.22.15.06.23; Thu, 22 Dec 2022 15:06:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FfldrF5j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231259AbiLVXFQ (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Thu, 22 Dec 2022 18:05:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbiLVXFK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Dec 2022 18:05:10 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21CB227171 for <linux-kernel@vger.kernel.org>; Thu, 22 Dec 2022 15:05:10 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id 23-20020a630017000000b0048d84f2cbbeso1757166pga.9 for <linux-kernel@vger.kernel.org>; Thu, 22 Dec 2022 15:05:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QBAw5tj+XZKcsIopd0PuHb+ptawoD6UcsAoOXegakKM=; b=FfldrF5j7ml2+CyoMh3UJZdx5Pxju6v8JLoR8Wzy2EtSgDfNcusRpSzdVQZqNygCpn SZ3vOQ6VlsgZiFOoPcrXdy5xDFDbcJD/VaI9iTUAl7/NsaqKVRVqapxytseWUc4rxYBH xiqb0qD98zWkh6H6j4ELJo4ovoYeP0IZbdw854nhsTbtx2jvusYI+QDJDGyrw2+aM6H+ f7hkkezSm6ioLPf8mXrkiHjkzaSv4O6onclZxkidov4mde4JXNvddnVQ4rQkCr7Wvy7n kzX4IbhrucHz5Oi6mBMDXXoGgivY91w9kHq7+mGfV3bKJplyLAVLEEm+vqdg+WTgxOG0 lZgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QBAw5tj+XZKcsIopd0PuHb+ptawoD6UcsAoOXegakKM=; b=zXUtTvCUF1EXRnEzf1iFia0qzxRrcDmo7H36yrfEHd4uyc0m5/LTL9fcdyxtfYr4RQ 5lf/D9Q6puMu0RRkrd+9jaS1UZW7/ylxOKrEfoIewbNr9YvbCyOdt9JJU+D7g9A8jZip GgtadB+uAzBNm4R2LM9vU4eKPU0xRbqSQY8u1kyof5VUzHXTovBEuqAefWhvGFzCoigZ wjS1zJ8Y6n7Rx04PoVHJGvXvKStWD4nZZnuar8r1lIk0MyA3nS/3NgyXr+ytasUNBWg6 /bHFQJxLmqKcX86M2rkl3Tah2f0DU4BckbjW8m7MEpwA4UtMyNKzJSnl40kPoU+gawG/ AH8w== X-Gm-Message-State: AFqh2kredR17pwzhmJMP2emIZ8nGS3eJEQlCqVLivnV8bBFM7PZzH1oD eaS9teWZfkrfnGba6qer02qY186u/7cbLArT X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a17:90a:7083:b0:219:2d33:9504 with SMTP id g3-20020a17090a708300b002192d339504mr597027pjk.171.1671750309699; Thu, 22 Dec 2022 15:05:09 -0800 (PST) Date: Thu, 22 Dec 2022 23:04:57 +0000 In-Reply-To: <20221222230458.3828342-1-vannapurve@google.com> Mime-Version: 1.0 References: <20221222230458.3828342-1-vannapurve@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221222230458.3828342-2-vannapurve@google.com> Subject: [V3 PATCH 1/2] KVM: selftests: x86: Cache the cpu vendor type From: Vishal Annapurve <vannapurve@google.com> To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: pbonzini@redhat.com, shuah@kernel.org, bgardon@google.com, seanjc@google.com, oupton@google.com, peterx@redhat.com, vkuznets@redhat.com, dmatlack@google.com, pgonda@google.com, andrew.jones@linux.dev, Vishal Annapurve <vannapurve@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752957355591551883?= X-GMAIL-MSGID: =?utf-8?q?1752957355591551883?= |
Series |
Execute hypercalls from guests according to cpu
|
|
Commit Message
Vishal Annapurve
Dec. 22, 2022, 11:04 p.m. UTC
Query cpuid once per guest selftest and store the cpu vendor type so that
subsequent queries can reuse the cached cpu vendor type.
Signed-off-by: Vishal Annapurve <vannapurve@google.com>
---
.../selftests/kvm/lib/x86_64/processor.c | 33 ++++++++++++++++---
1 file changed, 28 insertions(+), 5 deletions(-)
Comments
On Thu, Dec 22, 2022, Vishal Annapurve wrote: > Query cpuid once per guest selftest and store the cpu vendor type so that > subsequent queries can reuse the cached cpu vendor type. > > Signed-off-by: Vishal Annapurve <vannapurve@google.com> > --- > .../selftests/kvm/lib/x86_64/processor.c | 33 ++++++++++++++++--- > 1 file changed, 28 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c > index 097cef430774..1e93bb3cb058 100644 > --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c > +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c > @@ -20,6 +20,9 @@ > > vm_vaddr_t exception_handlers; > > +static bool is_cpu_vendor_intel; > +static bool is_cpu_vendor_amd; > + > static void regs_dump(FILE *stream, struct kvm_regs *regs, uint8_t indent) > { > fprintf(stream, "%*srax: 0x%.16llx rbx: 0x%.16llx " > @@ -1017,18 +1020,36 @@ void kvm_x86_state_cleanup(struct kvm_x86_state *state) > free(state); > } > > -static bool cpu_vendor_string_is(const char *vendor) > +static void check_cpu_vendor(void) I don't love the name, "check" makes me think the purpose of the helper is to assert something. Maybe cache_cpu_vendor()? Though this might be a moot point (more at the end). > { > - const uint32_t *chunk = (const uint32_t *)vendor; > + const char *intel_id = "GenuineIntel"; > + const uint32_t *intel_id_chunks = (const uint32_t *)intel_id; > + const char *amd_id = "AuthenticAMD"; > + const uint32_t *amd_id_chunks = (const uint32_t *)amd_id; > + static bool cpu_vendor_checked; > uint32_t eax, ebx, ecx, edx; > > + if (cpu_vendor_checked) > + return; > + > cpuid(0, &eax, &ebx, &ecx, &edx); > - return (ebx == chunk[0] && edx == chunk[1] && ecx == chunk[2]); > + > + if (ebx == intel_id_chunks[0] && edx == intel_id_chunks[1] && > + ecx == intel_id_chunks[2]) Align indentation, should be: if (ebx == intel_id_chunks[0] && edx == intel_id_chunks[1] && ecx == intel_id_chunks[2]) > + is_cpu_vendor_intel = true; > + else { > + if (ebx == amd_id_chunks[0] && edx == amd_id_chunks[1] && > + ecx == amd_id_chunks[2]) Same here. > + is_cpu_vendor_amd = true; > + } Though that's likely a moot point since manually checking the chunks (multiple times!) is rather heinous. Just store the CPUID output into an array and then use strncmp() to check the vendor. Performance isn't a priority for this code. static void cache_cpu_vendor(void) { uint32_t ign, vendor[3]; static bool cached; if (cached) return; cpuid(0, &ign, &vendor[0], &vendor[2], &vendor[1]); is_cpu_vendor_intel = !strncmp((char *)vendor, "GenuineIntel", 12); is_cpu_vendor_amd = !strncmp((char *)vendor, "AuthenticAMD", 12); cached = true; } That said, I like the v2 approach a lot more, we just need to better name the host variables to make it very clear that the info being cached is the _host_ vendor, and then provide separate helpers that bypass caching (though I don't think there would be any users?), again with better names. The confidential VM use case, and really kvm_hypercall() in general, cares about the host vendor, i.e. which hypercall instruction won't fault. Actually, even fix_hypercall_test is in the same boat. I don't like auto-caching the guest info because unlike the host (assuming no shenanigans in a nested setup), the guest vendor string can be changed. I don't think it's likely that we'll have a test that wants to muck with the vendor string on the fly, but it's not impossible, e.g. fix_hypercall_test dances pretty close to that. The independent guest vs. host caching in this version is also very subtle, though that can be solved with comments. E.g. first make is_intel_cpu() and is_amd_cpu() wrappers to non-caching helpers that use "this_cpu_..." naming to match other selftests code. Then rename is_intel_cpu() and is_amd_cpu() to is_{intel,amd}_host(), with a blurb in the changelog calling out that fix_hypercall_test wants the host vendor and also passes through the host CPUID vendor. And then do the precomputation stuff like in v2. E.g. for step #1 --- .../selftests/kvm/include/x86_64/processor.h | 22 +++++++++++++++++++ .../selftests/kvm/lib/x86_64/processor.c | 13 ++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index b1a31de7108a..34523a876336 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -554,6 +554,28 @@ static inline uint32_t this_cpu_model(void) return x86_model(this_cpu_fms()); } +static inline bool this_cpu_vendor_string_is(const char *vendor) +{ + const uint32_t *chunk = (const uint32_t *)vendor; + uint32_t eax, ebx, ecx, edx; + + cpuid(0, &eax, &ebx, &ecx, &edx); + return (ebx == chunk[0] && edx == chunk[1] && ecx == chunk[2]); +} + +static inline bool this_cpu_is_intel(void) +{ + return this_cpu_vendor_string_is("GenuineIntel"); +} + +/* + * Exclude early K5 samples with a vendor string of "AMDisbetter!" + */ +static inline bool this_cpu_is_amd(void) +{ + return this_cpu_vendor_string_is("AuthenticAMD"); +} + static inline uint32_t __this_cpu_has(uint32_t function, uint32_t index, uint8_t reg, uint8_t lo, uint8_t hi) { diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c index c4d368d56cfe..fae1a8a81652 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -1006,18 +1006,9 @@ void kvm_x86_state_cleanup(struct kvm_x86_state *state) free(state); } -static bool cpu_vendor_string_is(const char *vendor) -{ - const uint32_t *chunk = (const uint32_t *)vendor; - uint32_t eax, ebx, ecx, edx; - - cpuid(0, &eax, &ebx, &ecx, &edx); - return (ebx == chunk[0] && edx == chunk[1] && ecx == chunk[2]); -} - bool is_intel_cpu(void) { - return cpu_vendor_string_is("GenuineIntel"); + return this_cpu_is_intel(); } /* @@ -1025,7 +1016,7 @@ bool is_intel_cpu(void) */ bool is_amd_cpu(void) { - return cpu_vendor_string_is("AuthenticAMD"); + return this_cpu_is_amd(); } void kvm_get_cpu_address_width(unsigned int *pa_bits, unsigned int *va_bits) base-commit: d70e740240a298d0ff54d26f48f2fb034e3cb172 --
On Thu, Dec 22, 2022 at 4:24 PM Sean Christopherson <seanjc@google.com> wrote: > > ... > Though that's likely a moot point since manually checking the chunks (multiple > times!) is rather heinous. Just store the CPUID output into an array and then > use strncmp() to check the vendor. Performance isn't a priority for this code. > > static void cache_cpu_vendor(void) > { > uint32_t ign, vendor[3]; > static bool cached; > > if (cached) > return; > > cpuid(0, &ign, &vendor[0], &vendor[2], &vendor[1]); > > is_cpu_vendor_intel = !strncmp((char *)vendor, "GenuineIntel", 12); > is_cpu_vendor_amd = !strncmp((char *)vendor, "AuthenticAMD", 12); > > cached = true; > } You probably mean to suggest using memcmp here since this section will get executed from the guest context (which may not have access to strncmp). Makes sense to structure the implementation this way as I get more comfortable using string_override.c. > > That said, I like the v2 approach a lot more, we just need to better name the > host variables to make it very clear that the info being cached is the _host_ > vendor, and then provide separate helpers that bypass caching (though I don't > think there would be any users?), again with better names. > > The confidential VM use case, and really kvm_hypercall() in general, cares about > the host vendor, i.e. which hypercall instruction won't fault. Actually, even > fix_hypercall_test is in the same boat. > Ok, I misunderstood the earlier discussion [1] about using host cpuid to check the vendor type instead of the guest cpuid being problematic. If all the current and foreseeable users would be ok with native hypercall using host cpuid then I will fall back to approach in V2. [1] https://lore.kernel.org/lkml/Y1Hhw40H58EmZ6lK@google.com/ > I don't like auto-caching the guest info because unlike the host (assuming no > shenanigans in a nested setup), the guest vendor string can be changed. I don't > think it's likely that we'll have a test that wants to muck with the vendor string > on the fly, but it's not impossible, e.g. fix_hypercall_test dances pretty close > to that. > > The independent guest vs. host caching in this version is also very subtle, though > that can be solved with comments. > > E.g. first make is_intel_cpu() and is_amd_cpu() wrappers to non-caching helpers > that use "this_cpu_..." naming to match other selftests code. Then rename > is_intel_cpu() and is_amd_cpu() to is_{intel,amd}_host(), with a blurb in the > changelog calling out that fix_hypercall_test wants the host vendor and also passes > through the host CPUID vendor. And then do the precomputation stuff like in v2. > > E.g. for step #1 > > --- > .../selftests/kvm/include/x86_64/processor.h | 22 +++++++++++++++++++ > .../selftests/kvm/lib/x86_64/processor.c | 13 ++--------- > 2 files changed, 24 insertions(+), 11 deletions(-) > > diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h > index b1a31de7108a..34523a876336 100644 > --- a/tools/testing/selftests/kvm/include/x86_64/processor.h > +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h > @@ -554,6 +554,28 @@ static inline uint32_t this_cpu_model(void) > return x86_model(this_cpu_fms()); > } > > +static inline bool this_cpu_vendor_string_is(const char *vendor) > +{ > + const uint32_t *chunk = (const uint32_t *)vendor; > + uint32_t eax, ebx, ecx, edx; > + > + cpuid(0, &eax, &ebx, &ecx, &edx); > + return (ebx == chunk[0] && edx == chunk[1] && ecx == chunk[2]); > +} > + > +static inline bool this_cpu_is_intel(void) > +{ > + return this_cpu_vendor_string_is("GenuineIntel"); > +} > + > +/* > + * Exclude early K5 samples with a vendor string of "AMDisbetter!" > + */ > +static inline bool this_cpu_is_amd(void) > +{ > + return this_cpu_vendor_string_is("AuthenticAMD"); > +} > + > static inline uint32_t __this_cpu_has(uint32_t function, uint32_t index, > uint8_t reg, uint8_t lo, uint8_t hi) > { > diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c > index c4d368d56cfe..fae1a8a81652 100644 > --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c > +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c > @@ -1006,18 +1006,9 @@ void kvm_x86_state_cleanup(struct kvm_x86_state *state) > free(state); > } > > -static bool cpu_vendor_string_is(const char *vendor) > -{ > - const uint32_t *chunk = (const uint32_t *)vendor; > - uint32_t eax, ebx, ecx, edx; > - > - cpuid(0, &eax, &ebx, &ecx, &edx); > - return (ebx == chunk[0] && edx == chunk[1] && ecx == chunk[2]); > -} > - > bool is_intel_cpu(void) > { > - return cpu_vendor_string_is("GenuineIntel"); > + return this_cpu_is_intel(); > } > > /* > @@ -1025,7 +1016,7 @@ bool is_intel_cpu(void) > */ > bool is_amd_cpu(void) > { > - return cpu_vendor_string_is("AuthenticAMD"); > + return this_cpu_is_amd(); > } > > void kvm_get_cpu_address_width(unsigned int *pa_bits, unsigned int *va_bits) > > base-commit: d70e740240a298d0ff54d26f48f2fb034e3cb172 > -- > Ack.
diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c index 097cef430774..1e93bb3cb058 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -20,6 +20,9 @@ vm_vaddr_t exception_handlers; +static bool is_cpu_vendor_intel; +static bool is_cpu_vendor_amd; + static void regs_dump(FILE *stream, struct kvm_regs *regs, uint8_t indent) { fprintf(stream, "%*srax: 0x%.16llx rbx: 0x%.16llx " @@ -1017,18 +1020,36 @@ void kvm_x86_state_cleanup(struct kvm_x86_state *state) free(state); } -static bool cpu_vendor_string_is(const char *vendor) +static void check_cpu_vendor(void) { - const uint32_t *chunk = (const uint32_t *)vendor; + const char *intel_id = "GenuineIntel"; + const uint32_t *intel_id_chunks = (const uint32_t *)intel_id; + const char *amd_id = "AuthenticAMD"; + const uint32_t *amd_id_chunks = (const uint32_t *)amd_id; + static bool cpu_vendor_checked; uint32_t eax, ebx, ecx, edx; + if (cpu_vendor_checked) + return; + cpuid(0, &eax, &ebx, &ecx, &edx); - return (ebx == chunk[0] && edx == chunk[1] && ecx == chunk[2]); + + if (ebx == intel_id_chunks[0] && edx == intel_id_chunks[1] && + ecx == intel_id_chunks[2]) + is_cpu_vendor_intel = true; + else { + if (ebx == amd_id_chunks[0] && edx == amd_id_chunks[1] && + ecx == amd_id_chunks[2]) + is_cpu_vendor_amd = true; + } + cpu_vendor_checked = true; } bool is_intel_cpu(void) { - return cpu_vendor_string_is("GenuineIntel"); + check_cpu_vendor(); + + return is_cpu_vendor_intel; } /* @@ -1036,7 +1057,9 @@ bool is_intel_cpu(void) */ bool is_amd_cpu(void) { - return cpu_vendor_string_is("AuthenticAMD"); + check_cpu_vendor(); + + return is_cpu_vendor_amd; } void kvm_get_cpu_address_width(unsigned int *pa_bits, unsigned int *va_bits)