Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1793531pxy; Fri, 23 Apr 2021 17:50:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0jtkmDT5cqMfYJodr154U3jvAKg8X4LrYoydnNlnN17YErcrXaBmHkHVZ/KWVHRtU21pT X-Received: by 2002:a17:906:3c55:: with SMTP id i21mr6871540ejg.391.1619225457566; Fri, 23 Apr 2021 17:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619225457; cv=none; d=google.com; s=arc-20160816; b=ObOi702JGAjt+niS1z2M2nP5+P30PWgAug+sG66atKXmNKTnKm+6Iskr5yZf+BWGVH 0nMcxr1eCyDoCEbe7LA11wN5GGSbqhrsCpzLv2Lo6eK6PGvEl/4PTtUMKLSqQ3rwchaX 7DNbxmPW4cFz07xiJhX9Kfcn9u7LEzjoBKwSJtuEOL9xIUpUzMg5QE7Q5xS+kikg7zq6 IJZD1K8JdwblWm7lDlnV59j9FytYK6hXFTtk1ktnI/PaQ2zl2w+7ohngXhMhgIRiqGCo 8q82FSVtQ2y5y+tJIrzge4fbBNSLqx6FAUcQYt9w/X1CTysFHY/wQaGhQzUzWKh8p/J0 4RUg== 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:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=WDHyTgGjim6hk3/xd8JtlILQjW4Wl2Ft0fupXNYGdHc=; b=tIpHO5KHDXDa88hwSZeyVT9BM4IWN5b90qFyrvcamqeks3to5NyFsVyF9X2BGRNtOr bCku5C2VZO5koKRxGhh0BJ5aGAavd5pOS+wdZve+eZ2VVFJWigT6ujhYfEXu52BvGTqs EDnl3KBisuNhJacAKKAlCxE0Yk9Z9UmIbd/0Uog4qJE2JivPUVihw7wxTYfcwkKfpWsP 9ntvXOaCueyx7ubO3sHeWiMEmnH6zuA6vUqkKcDGVKIjnXEfYQ+czdn3sr8/Nvt/THWJ I06oIyy+QYRllG6EUnFZPUsUC5CqWDbfcQNkthHKpfBfBwdFdTY2GHWJTAu+gJ6upwUc rsSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rvQnQvoP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kl2si7872137ejc.82.2021.04.23.17.50.34; Fri, 23 Apr 2021 17:50:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rvQnQvoP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S244167AbhDXAr6 (ORCPT + 99 others); Fri, 23 Apr 2021 20:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244109AbhDXArr (ORCPT ); Fri, 23 Apr 2021 20:47:47 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F99FC061574 for ; Fri, 23 Apr 2021 17:47:07 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id l19-20020a37f5130000b02902e3dc23dc92so11863360qkk.15 for ; Fri, 23 Apr 2021 17:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=WDHyTgGjim6hk3/xd8JtlILQjW4Wl2Ft0fupXNYGdHc=; b=rvQnQvoP00Y7thOgQbkMO45k+pLyOLGgPtLCI27QOGyOOacF6s5jSWo7yThwKATN2j gRoqPUOPIg6AkpXdKzh/EdXAzIXyvJAbL3JyWI6e7MEPDQe5Y6KR/cpJzkbmQOo7Cv2g oqNuv3Vq4fCHXKP1dWMvFDgnu/lWiDStPzq0RDOJbXuuCyLYDo5CAX0P8NQM4GHHYW1C PSqUlcNQ7Ytju04V1UQmEuoFBdp8VIBcbY9o33dP8BY10NLdCjeURq/0yAP+zgFk/BMk OQYvtHz1eU0ypNg/RkrzVRr0Oi3Cht4n0S9STEhnJV+sNJ2/Bh8c9qaK9rP4cD83Lpgm pm/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=WDHyTgGjim6hk3/xd8JtlILQjW4Wl2Ft0fupXNYGdHc=; b=fxmbquGDmKPMMzrfRt61cAbBydQi+0E9EVqodS/YC2bd5Wf/NsXjGVhnaeEr/caX3n tacx1jtJZJGYIHNNqw5dpOZpwQcHHukFRQFw3FyFLtD4+AgWbjgR4CwPFK58a960GMH3 wv/jvA8bOS9XcZeZ/dY8KFvr/9hbkjKjSoVYV6JUncfn+nyr1WhByhuY2AiwIvFxNYDP T/yusQzTRzJ7gAvPVF/c5bIK2N3ZnCzv+QONqDncaB1+kUBt07EpJQ39Bd1Zuq2vxKgL l3RTt9xc0u8dCT5sD7/0nnkhhTv2krimHtIJG395s7m6ySQoV812T5xZDL4sHF+zkoSA 2U9Q== X-Gm-Message-State: AOAM53092FF5/KkF1qMwj0vIsEtHqZzd1egaagzXw0aNA/TXBn55dePx oradfkCjDlm/G/8jA2kMsOFDmK3IJHk= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:ad52:3246:e190:f070]) (user=seanjc job=sendgmr) by 2002:a0c:f247:: with SMTP id z7mr7230997qvl.24.1619225226439; Fri, 23 Apr 2021 17:47:06 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 23 Apr 2021 17:46:05 -0700 In-Reply-To: <20210424004645.3950558-1-seanjc@google.com> Message-Id: <20210424004645.3950558-4-seanjc@google.com> Mime-Version: 1.0 References: <20210424004645.3950558-1-seanjc@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH 03/43] KVM: SVM: Require exact CPUID.0x1 match when stuffing EDX at INIT From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not allow an inexact CPUID "match" when querying the guest's CPUID.0x1 to stuff EDX during INIT. In the common case, where the guest CPU model is an AMD variant, allowing an inexact match is a nop since KVM doesn't emulate Intel's goofy "out-of-range" logic for AMD and Hygon. If the vCPU model happens to be an Intel variant, an inexact match is possible if and only if the max CPUID leaf is precisely '0'. Aside from the fact that there's probably no CPU in existence with a single CPUID leaf, if the max CPUID leaf is '0', that means that CPUID.0.EAX is '0', and thus an inexact match for CPUID.0x1.EAX will also yield '0'. So, with lots of twisty logic, no functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 14ff7f0963e9..b9e3229ddc27 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1299,7 +1299,7 @@ static void svm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) } init_vmcb(vcpu); - kvm_cpuid(vcpu, &eax, &dummy, &dummy, &dummy, false); + kvm_cpuid(vcpu, &eax, &dummy, &dummy, &dummy, true); kvm_rdx_write(vcpu, eax); if (kvm_vcpu_apicv_active(vcpu) && !init_event) -- 2.31.1.498.g6c1eba8ee3d-goog