Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1720757pxj; Wed, 19 May 2021 12:17:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcUMgx8v34e27RUgEOuoZ5vRaBd9o+eunn4J4Yl8lDtFHNu7TmhKUP8tmUofLYQ6NLfGw4 X-Received: by 2002:a05:6402:268c:: with SMTP id w12mr667937edd.234.1621451864007; Wed, 19 May 2021 12:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621451864; cv=none; d=google.com; s=arc-20160816; b=mQI9yVxFnZMmsURTMVi9lj9YGv2+K1+h9uPukmdyYN86YIK9ytkN7fYgV+C5LUEjfL MZIJvg01WUKwNJtrDs/RTYcLxECfM6/Y0/bfzWnrV21r/HHhQFLV6EKgGzgZhvaOXWf9 QoR4+Srb0FppiThxxKK9Bs9eZai6oAgJmu+AwyiXzr9nXm46QuEESr9+zwDrF4O61eUx Hxx7zzI343ZWSbsQu3MMkAXKd5bWB2DHB0ZSIHManE/Gf/hTVDAtMgy0Zho8P/LY/llk N/3QPqHGOBVdA/+WakKTe5m6wpzZirVQXBiaKSdFCUdbp3B9+nuFmZn5jENmSU1aKZf8 2Ohw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1Ao//7r1KFld4qVZ1tXpzzorSlFP6vtsPLPVYqG20G0=; b=gc+DiHhcrW0z8QHVFbtAHLHJ5hFBJGYsfkNi35JVI0T6Ljp/yNm7Enn7KYzsSegH3U aRy6QbYM+klAXN9Tgkb6LQgf+Z85IZx8n21wh/YGscmZj2bGbygQtc7sbbbq0S46MjO0 SJVvYrCXgbXR0Qi3Xw8cTkQ78vzcVF0dtwr19uR9Pk6IRhbeC1W2HuItLSch9Cws0Qph hOFFdK8iO5RBPJ/136JMEMtDG2DMAE+ue8d5o3cJdu82hy9EmmzdZAzTedDS/1n/4sd6 RjzXztQeYgN7u70JP5JXh85KTAsFOTlBMe6Dhn+h632z6rOnaGtCpEwTV67NOX/nvkgD 9NYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DigzqK4G; 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 eb13si123730edb.95.2021.05.19.12.17.19; Wed, 19 May 2021 12:17:43 -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=DigzqK4G; 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 S245108AbhESFsA (ORCPT + 99 others); Wed, 19 May 2021 01:48:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348866AbhESFpa (ORCPT ); Wed, 19 May 2021 01:45:30 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E54C061342 for ; Tue, 18 May 2021 22:41:57 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id ot16so4824119pjb.3 for ; Tue, 18 May 2021 22:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1Ao//7r1KFld4qVZ1tXpzzorSlFP6vtsPLPVYqG20G0=; b=DigzqK4GdOu/HgdltA+7CkfEWC3DDrxUDEut8nZl4w7mYY+abYcumxMRYwNdPazlcQ hZwdeOoqQCRyH/IJVIbx7u5JsEQp3koYrSAcUu4Bs7dqaOGtc85ogx64GdzwfXAiYg4y gHaRXNUYM7ssVx4xi/bK+U1B5bubY4WMmSDxEsoVgO4TJ0eN+sHUkahea23M1/XXuigN 4nY3uekDRNR/xaeR049tVB1HXhOihgQFOwE4TY8QnVdMGtkYOCLTJ5OBybaqnjV7MCAq Qnooo2JEOMCg0CrikKZi9PPskMSLvrWWhPdRQfoQvl1Nwfz4AZSdTsiBAhHBNguFGjv+ L1yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1Ao//7r1KFld4qVZ1tXpzzorSlFP6vtsPLPVYqG20G0=; b=pnLH9PQ4+jB465f4tMUKWCpn1kXJb95KtnmsQV4Zl6fJRMqZgYj4vwVB7Y97cYlQos 0BHGh0jWcgwNZb7p6Fv/iGJMAJ2Xern8x33cCgP6hK1WYJLLAsM93zb76YwEjzEfAqhT iOCj4zXB8zP2NCjCVntUKkXYNP+XTi5l0rCvsjgiCH/c7iT2eENYydzEQ6zVF4p2PMZX qFyEJ9wAWtSfCCgKnkSJDF120Fx9uLIGRQzdAp98vaPVIY3Jq7NpKmpzE7HAm5LpH8JL GrsbAl/RMgo/S9gtgNz9888Ze114A2ilcMbwrAcOLh7/UZuElSN2iZlMzK5LUgb+F9E6 YwyA== X-Gm-Message-State: AOAM530Q0unYlag9YlbPjhdeSRirQSv5xImcLpEG9v8v+YT8aZekKaxY YNWHzqRhvzbzOhFtxbD2eNMpEhJ5liadzA1uFOmo2A== X-Received: by 2002:a17:90b:1185:: with SMTP id gk5mr5813526pjb.168.1621402917077; Tue, 18 May 2021 22:41:57 -0700 (PDT) MIME-Version: 1.0 References: <20210424004645.3950558-1-seanjc@google.com> <20210424004645.3950558-5-seanjc@google.com> In-Reply-To: <20210424004645.3950558-5-seanjc@google.com> From: Reiji Watanabe Date: Tue, 18 May 2021 22:41:40 -0700 Message-ID: Subject: Re: [PATCH 04/43] KVM: SVM: Fall back to KVM's hardcoded value for EDX at RESET/INIT To: Sean Christopherson Cc: Paolo Bonzini , 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 On Fri, Apr 23, 2021 at 5:47 PM Sean Christopherson wrote: > > At vCPU RESET/INIT (mostly RESET), stuff EDX with KVM's hardcoded, > default Family-Model-Stepping ID of 0x600 if CPUID.0x1 isn't defined. > At RESET, the CPUID lookup is guaranteed to "miss" because KVM emulates > RESET before exposing the vCPU to userspace, i.e. userspace can't > possibly have done set the vCPU's CPUID model, and thus KVM will always > write '0'. At INIT, using 0x600 is less bad than using '0'. > > While initializing EDX to '0' is _extremely_ unlikely to be noticed by > the guest, let alone break the guest, and can be overridden by > userspace for the RESET case, using 0x600 is preferable as it will allow > consolidating the relevant VMX and SVM RESET/INIT logic in the future. > And, digging through old specs suggests that neither Intel nor AMD have > ever shipped a CPU that initialized EDX to '0' at RESET. > > Regarding 0x600 as KVM's default Family, it is a sane default and in > many ways the most appropriate. Prior to the 386 implementations, DX > was undefined at RESET. With the 386, 486, 586/P5, and 686/P6/Athlon, > both Intel and AMD set EDX to 3, 4, 5, and 6 respectively. AMD switched > to using '15' as its primary Family with the introduction of AMD64, but > Intel has continued using '6' for the last few decades. > > So, '6' is a valid Family for both Intel and AMD CPUs, is compatible > with both 32-bit and 64-bit CPUs (albeit not a perfect fit for 64-bit > AMD), and of the common Families (3 - 6), is the best fit with respect to > KVM's virtual CPU model. E.g. prior to the P6, Intel CPUs did not have a > STI window. Modern operating systems, Linux included, rely on the STI > window, e.g. for "safe halt", and KVM unconditionally assumes the virtual > CPU has an STI window. Thus enumerating a Family ID of 3, 4, or 5 would > be provably wrong. > > Opportunistically remove a stale comment. > > Fixes: 66f7b72e1171 ("KVM: x86: Make register state after reset conform to specification") > Signed-off-by: Sean Christopherson Reviewed-by: Reiji Watanabe