From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7E8CC433ED for ; Sat, 24 Apr 2021 00:47:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94D3061463 for ; Sat, 24 Apr 2021 00:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232614AbhDXAr4 (ORCPT ); Fri, 23 Apr 2021 20:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237320AbhDXAro (ORCPT ); Fri, 23 Apr 2021 20:47:44 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AF30C06175F for ; Fri, 23 Apr 2021 17:47:05 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id y14-20020a0cf14e0000b029019ff951fd16so18531651qvl.12 for ; Fri, 23 Apr 2021 17:47:05 -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=qhJeA9fQsblztcKyPyMtaBD+iwF8KjnP8LQXx6xVt+Y=; b=b3hY/U1WaneYQzBX9CN0ubCT32hE7hloWZQl65LI4eOUrh2+bCCLjcGsK2HvWOnJpg sBdJcC9mDoOMsLXUUS9kQD/3X5H/CcZLA/Eu6/ssiSu2KlTk+u2hrcofJqqKfoCqCauZ u+SI3MhCXDJOhIOavHtb6eda4e+B49L6lq5e/0STCZqREnb3SRT7HHjzTfdatDkVET+/ 0vOobWHTBwTP6Q37Za+FXkozTubZLUJjxuivp2cf6iN2odnT/Uu+Zgij495RzNj/le8U R53bGc1k9EXAJf562dRE4GHwbMY6+Cr1bCcZWozxeuEU20vhS16WbFUKio0F/9kLuZfV v0nA== 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=qhJeA9fQsblztcKyPyMtaBD+iwF8KjnP8LQXx6xVt+Y=; b=T7VaTorONMO4r1kK1T+onU9Y4iYBo6Qu7GtYjqtKFD5ySVUbSf8H2RcsOaOYWGj7rF +UEsAN1E3HFKsrGQ213xarOA9XTpME4zWtrN7UCiXT8gObZjm0NZxzHzasaPCj7pGGQ3 NDuOi7Ckx7ONPnWlPgZgz0MGbhaC8iKahknN3v5AYo6yhRrIUCMu+qnqGOZNWM2hGZLS RAsh5g/Rg6GMcC/BIdAbCzKEXyccXToZOgv4jJNeHM3rPmwpnNyLdwYVTjBjto3QmY+f j4zlDLdbOlY0ivVlj1LXO+M9gJOx4o4sxTzbGeOkOT9R2eIkDBnAUuLF9bsOwESmicKH nX6w== X-Gm-Message-State: AOAM532ey2brn0ye/rhkwCSRn02BWi9yV8FwKv/VizhVzEnpKga1J2y5 m5U9bJPtcCUCg8iU4njbUZh1oj0FQ1w= X-Google-Smtp-Source: ABdhPJyDQMKu2bPxJQfGop/kTOzjGyE4dTxY0BImHfkaNpq+Ou8R2DmlzmPCu2WWxy1hBBcaH1nOFkenA/M= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:ad52:3246:e190:f070]) (user=seanjc job=sendgmr) by 2002:a0c:e950:: with SMTP id n16mr7445105qvo.43.1619225224151; Fri, 23 Apr 2021 17:47:04 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 23 Apr 2021 17:46:04 -0700 In-Reply-To: <20210424004645.3950558-1-seanjc@google.com> Message-Id: <20210424004645.3950558-3-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 02/43] KVM: VMX: Set EDX at INIT with CPUID.0x1, Family-Model-Stepping 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 Set EDX at RESET/INIT based on the userspace-defined CPUID model when possible, i.e. when CPUID.0x1.EAX is defined by userspace. At RESET/INIT, all CPUs that support CPUID set EDX to the FMS enumerated in CPUID.0x1.EAX. If no CPUID match is found, fall back to KVM's default of 0x600 (Family '6'), which is the least awful approximation of KVM's virtual CPU model. Fixes: 6aa8b732ca01 ("[PATCH] kvm: userspace interface") Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index a182cae71044..9c00d013af59 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4497,6 +4497,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) { struct vcpu_vmx *vmx = to_vmx(vcpu); struct msr_data apic_base_msr; + u32 eax, dummy; u64 cr0; vmx->rmode.vm86_active = 0; @@ -4504,7 +4505,11 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) vmx->msr_ia32_umwait_control = 0; - vmx->vcpu.arch.regs[VCPU_REGS_RDX] = get_rdx_init_val(); + eax = 1; + if (!kvm_cpuid(vcpu, &eax, &dummy, &dummy, &dummy, true)) + eax = get_rdx_init_val(); + kvm_rdx_write(vcpu, eax); + vmx->hv_deadline_tsc = -1; kvm_set_cr8(vcpu, 0); -- 2.31.1.498.g6c1eba8ee3d-goog