From patchwork Fri Oct 27 20:49:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 159154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp875440vqb; Fri, 27 Oct 2023 13:50:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1mJsUKxSNGH89KefHKTJ2JXAV6vdvQtwhN1d7EqQNyRvjOEGhGnNxc+aen16SfiM8zgXW X-Received: by 2002:a05:6a00:2443:b0:68f:b5cb:ced0 with SMTP id d3-20020a056a00244300b0068fb5cbced0mr3954804pfj.34.1698439800954; Fri, 27 Oct 2023 13:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698439800; cv=none; d=google.com; s=arc-20160816; b=lLPgB4jO9mFO8CT2Q72/WprmxtQXz3CaDyEHUo7WsuDpPi768Uix9uCFOd54X9wDoM TgR07qK7INLtEzdsvXXJx+vV5eP7Vx8F8uLHlcU5lC+h5Gm6higifrgkmWOzsHYLZx9X djpj7UqAnPuyBV4gvyL/YpF1arrSMoVquKPddut1nBTUF22+C34ZUivwn5Lv9uCn5wJK R36myK+DJiUxtl9b5pXrCrab6JohzNYnxorXxN/D92q6eKyooPwGM6a1l6gjRpUxVECW d8x4T7PZEocDEe7zEnNePhmR3Nevrs28XXasuvvoKmNyy2792X0OeXAQ6QBLQaVj8kvO GJ8Q== 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:reply-to:dkim-signature; bh=di11lWawOmLCcXEAkUakkRrsqpIr6RYJN4TydENb44I=; fh=dogxdQWc7Q2U5Ekp9F18wEHwMgE3kRwQ/60KgTj3654=; b=kDU1mQ/ITxWieTSlwPs2cwKAmbtZJZJAg73t2ZKkLDFXrsBwO+FQjjlSBGnsy0QIaS L8r5ghiL9YUACbhNDFfPhC506+gLev+HzRjUgng1puZgsejU3By6B29ryQ7BQBRdpmbn z6HXXmwPySA+GIqC5ko+6Q5n5HJHdTn/bgCpvF/6dm2xqaijlKysHqclzX7F4bvuNwul CGL6YKVd2CUjQkinWCi6JR8EWQDdkiuoI7mIhRUH7HPvDSj7ut2dKuZ8xGLCmMbGPCdG c9/WVqZ/W2O2EwS3Nn7yb7I70IaMktQkLyt2Y8m5UkJvHXxqp/FO7aIDiJruAztrGL9g FGCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vuQo9lr2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q21-20020a656855000000b00574035fd472si1477647pgt.31.2023.10.27.13.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 13:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vuQo9lr2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 06D1880AB1F1; Fri, 27 Oct 2023 13:50:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346563AbjJ0Utt (ORCPT + 27 others); Fri, 27 Oct 2023 16:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346523AbjJ0Utp (ORCPT ); Fri, 27 Oct 2023 16:49:45 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F32AF1B9 for ; Fri, 27 Oct 2023 13:49:42 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-5b7bf88d712so1351160a12.1 for ; Fri, 27 Oct 2023 13:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698439782; x=1699044582; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=di11lWawOmLCcXEAkUakkRrsqpIr6RYJN4TydENb44I=; b=vuQo9lr2Pg5EwCwgzhYdltwG4B8DOCJcgzrfLOX6yiCsGAWjpXxutiv1fRg8N4QOcI 6Y6p6Vh37qBmYo5COVLuOZXdY2aXJz/utC3QLk93IjbvAEVbqMsjF24lgYr0xD9kFC1o 0cLEM7PZR2Nk18mSK3KaCvAYOjP4i9LvSA8oWDivVX/GXDqAMJClYY4m3du664AlIQzU BKmA1s/aEu0BfS/JWJr5/zv8fzCyo2efkupLS8ihW33Wym8MC3I2L4UTpLa+qMZmFr+k wMGeyQ1IiEUjM+J5cSKwPPPzddOAoUYhu3mqOXfITP2bOTBf7fJqCfaKECzkSeULbLyM 6a+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698439782; x=1699044582; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=di11lWawOmLCcXEAkUakkRrsqpIr6RYJN4TydENb44I=; b=bioRytMTNl9j4PXR+G6V6IoRTivFnISKjAJQBAZCSNTLsy0y7CTNtzhhcPXvbaCQ54 2Fkwfpo0xGY4DcmJHni15oPZxDk49C0bUpX9ydEFxpjB7ztnESAzQUM0K7Sh3gmdkHSl ES2ZC152t0x8ByvRKg5YxTOyqiorxlgXAE0JodCfdO8+8Swg3EfcHns4Tk2kjGPhi0/q aIRv76yFXhltznXv+p1CNC2NtbGvEY44LTpq7YQeprQrcYGwkBJ1z/gIZMIJ5M63Hngp iu5XnxkWpwfrcUkGdXaJBu6u2fekOfLWR971VHHomahRVy4MsU7M3EPkp4/85er0IcYb YBmg== X-Gm-Message-State: AOJu0YxBhIXqpK7tZ3O/TEQWkuh9nhAT1/v2obqI2g8hP2RXTt6ru3rW FBcYzUb48J8JuAN+Br+7kIxiHN1BD2I= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:ad49:0:b0:5b9:2ff5:1fc9 with SMTP id y9-20020a63ad49000000b005b92ff51fc9mr94769pgo.5.1698439782477; Fri, 27 Oct 2023 13:49:42 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 27 Oct 2023 13:49:27 -0700 In-Reply-To: <20231027204933.3651381-1-seanjc@google.com> Mime-Version: 1.0 References: <20231027204933.3651381-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231027204933.3651381-4-seanjc@google.com> Subject: [GIT PULL] KVM: x86: Misc changes for 6.7 From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson 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_BLOCKED,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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 27 Oct 2023 13:50:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780943212967475581 X-GMAIL-MSGID: 1780943212967475581 A truly miscellaneous collection of patches this time around. David M's PML fix obviously belongs in the MMU pull request, but I applied it to the wrong branch and didn't want to rebase for such a silly thing. The following changes since commit 5804c19b80bf625c6a9925317f845e497434d6d3: Merge tag 'kvm-riscv-fixes-6.6-1' of https://github.com/kvm-riscv/linux into HEAD (2023-09-23 05:35:55 -0400) are available in the Git repository at: https://github.com/kvm-x86/linux.git tags/kvm-x86-misc-6.7 for you to fetch changes up to 2770d4722036d6bd24bcb78e9cd7f6e572077d03: KVM: x86: Ignore MSR_AMD64_TW_CFG access (2023-10-19 10:55:14 -0700) ---------------------------------------------------------------- KVM x86 misc changes for 6.7: - Add CONFIG_KVM_MAX_NR_VCPUS to allow supporting up to 4096 vCPUs without forcing more common use cases to eat the extra memory overhead. - Add IBPB and SBPB virtualization support. - Fix a bug where restoring a vCPU snapshot that was taken within 1 second of creating the original vCPU would cause KVM to try to synchronize the vCPU's TSC and thus clobber the correct TSC being set by userspace. - Compute guest wall clock using a single TSC read to avoid generating an inaccurate time, e.g. if the vCPU is preempted between multiple TSC reads. - "Virtualize" HWCR.TscFreqSel to make Linux guests happy, which complain about a "Firmware Bug" if the bit isn't set for select F/M/S combos. - Don't apply side effects to Hyper-V's synthetic timer on writes from userspace to fix an issue where the auto-enable behavior can trigger spurious interrupts, i.e. do auto-enabling only for guest writes. - Remove an unnecessary kick of all vCPUs when synchronizing the dirty log without PML enabled. - Advertise "support" for non-serializing FS/GS base MSR writes as appropriate. - Use octal notation for file permissions through KVM x86. - Fix a handful of typo fixes and warts. ---------------------------------------------------------------- David Matlack (1): KVM: x86/mmu: Stop kicking vCPUs to sync the dirty log when PML is disabled David Woodhouse (1): KVM: x86: Refine calculation of guest wall clock to use a single TSC read Dongli Zhang (1): KVM: x86: remove always-false condition in kvmclock_sync_fn Jim Mattson (4): KVM: x86: Allow HWCR.McStatusWrEn to be cleared once set KVM: x86: Virtualize HWCR.TscFreqSel[bit 24] KVM: selftests: Test behavior of HWCR, a.k.a. MSR_K7_HWCR x86: KVM: Add feature flag for CPUID.80000021H:EAX[bit 1] Josh Poimboeuf (2): KVM: x86: Add IBPB_BRTYPE support KVM: x86: Add SBPB support Kyle Meyer (1): KVM: x86: Add CONFIG_KVM_MAX_NR_VCPUS to allow up to 4096 vCPUs Liang Chen (1): KVM: x86: remove the unused assigned_dev_head from kvm_arch Like Xu (1): KVM: x86: Don't sync user-written TSC against startup values Maciej S. Szmigiero (1): KVM: x86: Ignore MSR_AMD64_TW_CFG access Michal Luczaj (2): KVM: x86: Remove redundant vcpu->arch.cr0 assignments KVM: x86: Force TLB flush on userspace changes to special registers Mingwei Zhang (1): KVM: x86: Update the variable naming in kvm_x86_ops.sched_in() Nicolas Saenz Julienne (1): KVM: x86: hyper-v: Don't auto-enable stimer on write from user-space Peng Hao (1): KVM: x86: Use octal for file permission arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/kvm_host.h | 12 +- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kvm/Kconfig | 11 ++ arch/x86/kvm/cpuid.c | 8 +- arch/x86/kvm/cpuid.h | 3 +- arch/x86/kvm/hyperv.c | 10 +- arch/x86/kvm/smm.c | 1 - arch/x86/kvm/svm/svm.c | 2 +- arch/x86/kvm/vmx/vmx.c | 20 +-- arch/x86/kvm/x86.c | 195 ++++++++++++++++----- arch/x86/kvm/x86.h | 1 + arch/x86/kvm/xen.c | 4 +- tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c | 47 +++++ 15 files changed, 251 insertions(+), 66 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c