Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp236835lqe; Thu, 4 Apr 2024 05:29:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaOSuCn0+Kl8wImgX3rwQH8E1BU2274mESSXP0Neudbgf2AIrbeJXSm4vJ8/U2NIeqdl7tiyQLeza7us88FAmFoBApylVF/f7/Mj4Vzw== X-Google-Smtp-Source: AGHT+IFZn75nYgIJT7uc8az6Siov/9LegAvh4yqbw3LfySF1EZA8cHgLa/9dzgGBqjXJzV7VEETN X-Received: by 2002:a05:6a20:e607:b0:1a7:1c26:f9ac with SMTP id my7-20020a056a20e60700b001a71c26f9acmr2541437pzb.62.1712233751285; Thu, 04 Apr 2024 05:29:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712233751; cv=pass; d=google.com; s=arc-20160816; b=Mc6jADkOa2/Sej0fh+TnHunyOsi6WaAEJRBEjZELhurX5zvYwdCe0E+a6cAxZGDdKe hQeXKOKVHGMkuN3b6i+0Qst2eHyro3YQ8UVtIJ3jr+VV9T2MjZotA2lMPoAu1FcK5khS 7X6bn58N5w9FePPeoXj/ctcbQkxvWFOePdD1XPGxU5BRtdSmHBv6F7NFqJwC8mniS0v1 l4X2jMfVFhVhTX8rTawti2TGvjc8ZIXX6AdMFATEmVmHYDIoSeIW1lFBQ6E0EuSrgrwx ix5PpZVIRcVu2tBvg5Bkqdk/6QWSCbI5GaId4q6xR7OewL+V7JJz5+uVNEVEdlwnYV7K x/gQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=iX8vkGO/ubhfuqfL3RRUiW2W1cfaaMsTND1lD88J4N4=; fh=VpAbevhaPZS8k6A1QyssQYWYLDLyTk/RBLlCDmpP0O8=; b=CNER8YPW/M8u1d1uYyUWLnt2nUSz76BlokJ4ChFAjnSFvTqsysxlRMvPIlE/jbSrVb sK9lWm9tPbDOodfEJYjjEdK6E620tXb12eQTu1xH/b2M3CvDErHJL0voBQwAUJXb6dUX 18AaxcVFYS4BrrHx66g3oHUIATNcW6zGZXG1VZWZ5fbQJgAsmHYmoJV2Mq/hLuyPsjk4 WVuNWE1VuzrlIZYd0UBYsw52jO1oNWhOkQIJNhoKvIaMPwRVzl4ZooUZs0o14VeVHmDq RB4AxWtKHO0nzz2IGHHfgaB3vs6OuJV3ncJJs9P8FMoXw1u2hUE9SlA/QAKu6/SKdNDM UIwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OuaKjKh1; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-131376-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b4-20020a170902e94400b001e2b75e37a7si628051pll.604.2024.04.04.05.29.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 05:29:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131376-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OuaKjKh1; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-131376-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6CC8A28731E for ; Thu, 4 Apr 2024 12:14:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E50A21272B5; Thu, 4 Apr 2024 12:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OuaKjKh1" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F30C585276 for ; Thu, 4 Apr 2024 12:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712232814; cv=none; b=BC+/7mgLXfdh+ZMor8XP59Tlhi12pWbGWN+I0iDCsvWyHlW2InbncFPhzI3Low9nuHc30C63g9+Qcp3C6X7nIbUJMOamasEnP9/80IfjlsZu+62btv7yNKIvDeuoFVJo7BGeHq3kKrwvztaDwPOi+wHmS7yRdNugcNJCwE90egY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712232814; c=relaxed/simple; bh=lvgrt2+h+32nV9sB6Pbowk90McEKUA04yJRDBc4Cfx4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=VJqAbamD0/hp3eabuxknQ3v+9OcviQqqIWABZo7xBgb+t+WUimJYKWJuyRnOzxRJPFidsIaDueudCXR+3QRvl1UwBlsre89VlyU5/y0HOkcwSvT2gRFxTpa2IhX4CaP/VwXF1AhmDM6q9S+nncQVYN2b4jipLw9Cxd92Z1vXsVo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OuaKjKh1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712232811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iX8vkGO/ubhfuqfL3RRUiW2W1cfaaMsTND1lD88J4N4=; b=OuaKjKh1mH0t16t2kPEQ434vdTnI10PsljGDbsVZkKs9pT/92cZCkI+PwqAjPA+Kiw0RcL 9H/ZlVbMzl891mnpAEhSbEHaxa6I/yoNb/ZCicLhmQr4SotEPR2bYwZf8FbZWKTzVkgBgH fZuB1yL/wRJnp8oM38soGCptWU5XI6c= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-zuCUrquIPS-saWkijWOZmg-1; Thu, 04 Apr 2024 08:13:28 -0400 X-MC-Unique: zuCUrquIPS-saWkijWOZmg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E06C383CCE8; Thu, 4 Apr 2024 12:13:28 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19086200A386; Thu, 4 Apr 2024 12:13:28 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: michael.roth@amd.com, isaku.yamahata@intel.com, Dave Hansen Subject: [PATCH v5 00/17] KVM: SEV: allow customizing VMSA features Date: Thu, 4 Apr 2024 08:13:10 -0400 Message-ID: <20240404121327.3107131-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 This is the same as v4, except for the following minor changes: - moving the KVM_X86_SEV_VMSA_FEATURES attribute to a separate group, KVM_X86_GRP_SEV [Isaku] - as part of the previous change, retroactively define group 0 as "KVM_X86_GRP_SYSTEM" - squashing in the "fixup! KVM: SEV: sync FPU and AVX state at LAUNCH_UPDATE_VMSA time" patch - disabling FPU and AVX sync for the old-style KVM_SEV_ES_INIT ioctl [Michael] - adding an fstp instruction to the new test case, in order to keep the x87 stack balanced (just for cleanliness/paranoia) Paolo Bonzini (16): KVM: SVM: Compile sev.c if and only if CONFIG_KVM_AMD_SEV=y KVM: x86: use u64_to_user_ptr() KVM: introduce new vendor op for KVM_GET_DEVICE_ATTR KVM: SEV: publish supported VMSA features KVM: SEV: store VMSA features in kvm_sev_info KVM: x86: add fields to struct kvm_arch for CoCo features KVM: x86: Add supported_vm_types to kvm_caps KVM: SEV: introduce to_kvm_sev_info KVM: SEV: define VM types for SEV and SEV-ES KVM: SEV: sync FPU and AVX state at LAUNCH_UPDATE_VMSA time KVM: SEV: introduce KVM_SEV_INIT2 operation KVM: SEV: allow SEV-ES DebugSwap again selftests: kvm: add tests for KVM_SEV_INIT2 selftests: kvm: switch to using KVM_X86_*_VM selftests: kvm: split "launch" phase of SEV VM creation selftests: kvm: add test for transferring FPU state into VMSA Sean Christopherson (1): KVM: SVM: Invert handling of SEV and SEV_ES feature flags Documentation/virt/kvm/api.rst | 2 + .../virt/kvm/x86/amd-memory-encryption.rst | 52 ++++- arch/x86/include/asm/fpu/api.h | 3 + arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h | 8 +- arch/x86/include/uapi/asm/kvm.h | 20 +- arch/x86/kernel/fpu/xstate.c | 1 + arch/x86/kernel/fpu/xstate.h | 2 - arch/x86/kvm/Makefile | 7 +- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/svm/sev.c | 190 ++++++++++++++---- arch/x86/kvm/svm/svm.c | 27 ++- arch/x86/kvm/svm/svm.h | 54 +++-- arch/x86/kvm/x86.c | 165 +++++++++------ arch/x86/kvm/x86.h | 2 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/kvm_util_base.h | 11 +- .../selftests/kvm/include/x86_64/processor.h | 6 - .../selftests/kvm/include/x86_64/sev.h | 19 +- tools/testing/selftests/kvm/lib/kvm_util.c | 1 - .../selftests/kvm/lib/x86_64/processor.c | 14 +- tools/testing/selftests/kvm/lib/x86_64/sev.c | 44 +++- .../selftests/kvm/set_memory_region_test.c | 8 +- .../selftests/kvm/x86_64/sev_init2_tests.c | 152 ++++++++++++++ .../selftests/kvm/x86_64/sev_smoke_test.c | 96 ++++++++- 25 files changed, 703 insertions(+), 185 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/sev_init2_tests.c -- 2.43.0