Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1792582pxy; Fri, 23 Apr 2021 17:48:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6Le/cDky1gpQDDrwA/iXUR0B4Ybsu9seKJ33Du0zPLe2fB09nLlbIf7a2Mh/AZmfRU9sz X-Received: by 2002:a17:907:1c01:: with SMTP id nc1mr6869997ejc.283.1619225319189; Fri, 23 Apr 2021 17:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619225319; cv=none; d=google.com; s=arc-20160816; b=foW3MbaPj6A+qroCB0dgtp4KX/LNUjYmL2967CcsF7K4ygOzAw/H64FQtWNQAhhEMB oIqrHealC8eoiRSYTa7eyQPWiuLOUc4rJ91++LbsfjkMcqzLrOrJLbDCjSFk0UsTDC8n eUyglfgoCxyny0Jl7ImKzlnqXAHmN+hs4mLV3z2jqLeZGJ7sfho2qj0rz3tqZvcZPmOj aFTlcCuJv23+JS8Y5fcT3TYp6h6SMkgydIBMBGDPFWlWt+OwfQ1J7e71k0swfxmSjvpg I2rs+DQI5qA8dtqbrSXX1y+7fAPULTvxK1GXtuJrogMjFtOd6C+ix4m0Om0U5QmhIKFl o6aQ== 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=qhJeA9fQsblztcKyPyMtaBD+iwF8KjnP8LQXx6xVt+Y=; b=EEr3xz0gbDD/GjIK/2y0vznrY8xQ80lV+9m0TRVOaJADQw0xOqgY0yTGSTY7q0gm0V kaw77DrREYhSeZ/ygols+hwon+KtfJiIoLdmcDWPCy1KG2OKxKCzsSy2oPcooKBgnfKu jJCP95bWMQUC7+C4h8ohShXP8Fk8FuSdXo+Q40H/dpZ2bIMG5DEZSrXKYDjDVtMcUhCj +wsgRcUVTz0IO3UI7sCLxN896x4ko+abK1A93LDGNac6vkEnL1Tduv1KR1YwzZhb8Jd4 KB6XHpO2iS0/N7mjVcZ1lLFT8vJnkQ8bQ891WNd/8de9FDreC3jIVx4Tq/uVIuZXrwjn KXTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="b3hY/U1W"; 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 fy26si6749234ejb.76.2021.04.23.17.48.16; Fri, 23 Apr 2021 17:48:39 -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="b3hY/U1W"; 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 S244183AbhDXArx (ORCPT + 99 others); Fri, 23 Apr 2021 20:47:53 -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-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