From patchwork Mon Jan 17 15:05:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 12715518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9C19C433EF for ; Mon, 17 Jan 2022 15:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240349AbiAQPFz (ORCPT ); Mon, 17 Jan 2022 10:05:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52735 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240340AbiAQPFz (ORCPT ); Mon, 17 Jan 2022 10:05:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642431954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EbDM4wu2EfidM+Hk/2ULEy/PRDdj2I7ZEN6bIKgp+Oo=; b=L270cDEk6d7+eUYwirLQLtSy/W8xmWgTUDOre+q3/ayT3ctlL323v2F+eI6N7vI5Uugt3h JBjD390dH7F1QZiAw8uABYocycNmbHPpck3B9FOhhBOMvV2xXLqrUPJz4Hkr+5g2o6Wqms aBp2eS0xHZ1DQlzR39xcneZTAJAt/5M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-354-YMwTSTYbMy6PWuxla2v57Q-1; Mon, 17 Jan 2022 10:05:51 -0500 X-MC-Unique: YMwTSTYbMy6PWuxla2v57Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73AFB1853028; Mon, 17 Jan 2022 15:05:49 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.195.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C9312B5AB; Mon, 17 Jan 2022 15:05:43 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Igor Mammedov , linux-kernel@vger.kernel.org Subject: [PATCH v2 0/4] KVM: x86: Partially allow KVM_SET_CPUID{,2} after KVM_RUN for CPU hotplug Date: Mon, 17 Jan 2022 16:05:38 +0100 Message-Id: <20220117150542.2176196-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Changes since v1: - Drop the allowlist of items which were allowed to change and just allow the exact same CPUID data [Sean, Paolo]. Adjust selftest accordingly. - Drop PATCH1 as the exact same change got merged upstream. Recently, KVM made it illegal to change CPUID after KVM_RUN but unfortunately this change is not fully compatible with existing VMMs. In particular, QEMU reuses vCPU fds for CPU hotplug after unplug and it calls KVM_SET_CPUID2. Relax the requirement by implementing an allowing KVM_SET_CPUID{,2} with the exact same data. Vitaly Kuznetsov (4): KVM: x86: Do runtime CPUID update before updating vcpu->arch.cpuid_entries KVM: x86: Partially allow KVM_SET_CPUID{,2} after KVM_RUN KVM: selftests: Rename 'get_cpuid_test' to 'cpuid_test' KVM: selftests: Test KVM_SET_CPUID2 after KVM_RUN arch/x86/kvm/cpuid.c | 67 ++++++++++++++++--- arch/x86/kvm/x86.c | 19 ------ tools/testing/selftests/kvm/.gitignore | 2 +- tools/testing/selftests/kvm/Makefile | 4 +- .../selftests/kvm/include/x86_64/processor.h | 7 ++ .../selftests/kvm/lib/x86_64/processor.c | 33 +++++++-- .../x86_64/{get_cpuid_test.c => cpuid_test.c} | 30 +++++++++ 7 files changed, 126 insertions(+), 36 deletions(-) rename tools/testing/selftests/kvm/x86_64/{get_cpuid_test.c => cpuid_test.c} (83%)