Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp807225pxb; Thu, 21 Oct 2021 09:50:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGKZM0Gn88+D3aZXvEVk1bne3g25P4QO+jMpwC1Syzj94OAIIn6DFutReSwRZw9hfJ1ZXL X-Received: by 2002:a17:902:b597:b0:13e:9ba6:fed with SMTP id a23-20020a170902b59700b0013e9ba60fedmr6345103pls.32.1634835022130; Thu, 21 Oct 2021 09:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634835022; cv=none; d=google.com; s=arc-20160816; b=wp15VCuWZ5hHET8BNJJFDebDkFw5FKQN1Bxb9nZ96pMxPDUK/bLVuJVjtXMIpRZNje prRdD4KCSwXmSsgVaYddIPapPaessYAzNdVIddV0wdMDSEoyMdCvBDLW0jYtaBZQPeHf 5HwNTcs3pVNWAQ+sh6u2F1ic8uc0RZEMLg6We8sdkjaG/QRfpJpEizYsdCG8t1ixbtyT VbL0ljL0Bpoc65STsbiXC0NjItegEeflwGRIQBwLDRfP619elD55PDBk2YY9XLC04Pv0 Fs1zcjWEr9eb5vGtHUvka7+CN8IQmL5UesKqhSHmBhD5T50QV6mgiNsTNzyvU0pfEXCn LhJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=VCfninvKWV47Xsp5RP9uGNnQM9wSoQBnNs6aRe8wJDY=; b=CpqdMhOgzYw1sLE5etccE/uB1FyEURZIqAH51dgkI3+azVTpkowxgrUpwrVLLibemt G5TVhvNG80l+vYYoe4AH0KTQ1z6PZ0ymW1IDSTssd7Wf2q3Fz/uJwKfM9eXvZ2jOLG19 kiN0Mt+jydQBz9nuEq9z/VblGEK0+IDWnzjTapTk6sqf1jTsf1hAQsfaBf3NekweNXdp Qrvfm7zmb7niRzDXHJWHvkIRmphiIgoAJwHa7IXmOcfFEg8PCTQoWPOJH1+3nzI0jSiQ 8gC2ENMgpVsyryXi5mT389LPampyQ0kUQFg94Ou6okKNvgtBbtfLbQPxYy//wegylJa2 H03g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TNNv8OEA; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g191si7962193pgc.270.2021.10.21.09.50.09; Thu, 21 Oct 2021 09:50:22 -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=@redhat.com header.s=mimecast20190719 header.b=TNNv8OEA; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232088AbhJUQuq (ORCPT + 99 others); Thu, 21 Oct 2021 12:50:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50647 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232042AbhJUQup (ORCPT ); Thu, 21 Oct 2021 12:50:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634834909; 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: in-reply-to:in-reply-to:references:references; bh=VCfninvKWV47Xsp5RP9uGNnQM9wSoQBnNs6aRe8wJDY=; b=TNNv8OEAK0ywbmQsRdJ68Km2fOXoAcbFYdWDP49DWxkQiEaswkqChlFEDbU27qltVwH94R ytdkCdFPrHiN98AL0DF2XtaQ2Pb//s4AvGDQmBjuhwmrnwR1VGjSLCXBIW1tXcTlAdQo0A TDQKCqtWp52lEZKVFIj4U+DbVKdkje0= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-eNY4Z6XOPp6hwWyOyt_lhA-1; Thu, 21 Oct 2021 12:48:28 -0400 X-MC-Unique: eNY4Z6XOPp6hwWyOyt_lhA-1 Received: by mail-ed1-f70.google.com with SMTP id t28-20020a508d5c000000b003dad7fc5caeso965308edt.11 for ; Thu, 21 Oct 2021 09:48:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=VCfninvKWV47Xsp5RP9uGNnQM9wSoQBnNs6aRe8wJDY=; b=bodTbtNLdCUAHf5JNiFmx5vcvxKjw7p4cq/vEmmur1Zm4E8KmxHm4b/DdytR6B376j lmTkeisNymsByYi8uEd0YICYo+fTknaheMopyzjDi1N8qBVYXKycn4pqwiGv5vnvogvi bpEZj/spSRcwdsu2YVnXSlUIdWsDCx8Hv9LiWlvkmmJS87xZ2/uJiOYXoCTTDoaHzXVL pVJzdhuAuJt3kaqmZzxokMYKR+m4CTJoV42ylGw/z2lVfJdfR9HpUyb1X8WEFyFT+CNM I+nVT0ACd2jH4SxvXltMm67Hgw/TcqZgCrL6GUGjj9Lzre16HsYuDxax9prBB6Z/f8a9 Yk/g== X-Gm-Message-State: AOAM530+gghcCFDA5k7vLij2qCgNLVJPaDtopll2JPC6l1D6bTQzZ0Ad IqUyvue2A64Nupc6sJmz8MvuOpXKU3o7RXDF88uSsa5y34XnsP71M3Oo0aM9BkUjobh4huIuYu4 /KwXriJ+GYQvoz8kqmjsAAD5w X-Received: by 2002:a05:6402:1d49:: with SMTP id dz9mr8906096edb.55.1634834907148; Thu, 21 Oct 2021 09:48:27 -0700 (PDT) X-Received: by 2002:a05:6402:1d49:: with SMTP id dz9mr8906052edb.55.1634834906943; Thu, 21 Oct 2021 09:48:26 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:63a7:c72e:ea0e:6045? ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id b2sm3206364edv.73.2021.10.21.09.48.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Oct 2021 09:48:26 -0700 (PDT) Message-ID: <71547952-c3e7-6683-5eea-70d3003d5224@redhat.com> Date: Thu, 21 Oct 2021 18:48:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [RFC 00/16] KVM: selftests: Add tests for SEV, SEV-ES, and SEV-SNP guests Content-Language: en-US To: Michael Roth , linux-kselftest@vger.kernel.org Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Nathan Tempelman , Marc Orr , Steve Rutherford , Sean Christopherson , Mingwei Zhang , Brijesh Singh , Tom Lendacky , Varad Gautam , Shuah Khan , Vitaly Kuznetsov , David Woodhouse , Ricardo Koller , Jim Mattson , Wanpeng Li , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" References: <20211005234459.430873-1-michael.roth@amd.com> From: Paolo Bonzini In-Reply-To: <20211005234459.430873-1-michael.roth@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/10/21 01:44, Michael Roth wrote: > These patches and are also available at: > > https://github.com/mdroth/linux/commits/sev-selftests-rfc1 > > They are based on top of v5 of Brijesh's SEV-SNP hypervisor patches[1] > to allow for SEV-SNP testing and provide some context for the overall > design, but the SEV/SEV-ES patches can be carved out into a separate > series as needed. > > == OVERVIEW == > > This series introduces a set of memory encryption-related parameter/hooks > in the core kselftest library, then uses the hooks to implement a small > library for creating/managing SEV, SEV-ES, SEV-SNP guests. This library > is then used to implement a basic boot/memory test that's run for all > variants of SEV/SEV-ES/SEV-SNP guest types, as well as a set of SEV-SNP > tests that cover various permutations of pvalidate/page-state changes. > > - Patches 1-7 implement SEV boot tests and should run against existing > kernels > - Patch 8 is a KVM changes that's required to allow SEV-ES/SEV-SNP > guests to boot with an externally generated page table, and is a > host kernel prequisite for the remaining patches in the series. > - Patches 9-12 extend the boot tests to cover SEV-ES > - Patches 13-16 extend the boot testst to cover SEV-SNP, and introduce > an additional test for page-state changes. Hi Mike, this SEV/SEV-ES testing (both your series and kvm-unit-tests) is good stuff. :) If you fix up patches 1-12, I will commit them pretty much straight away. The only thing that possibly needs some thought is the integration with ucall. Thanks, Paolo > Any review/comments are greatly appreciated! > > [1] https://lore.kernel.org/linux-mm/20210820155918.7518-1-brijesh.singh@amd.com/ > > ---------------------------------------------------------------- > Michael Roth (16): > KVM: selftests: move vm_phy_pages_alloc() earlier in file > KVM: selftests: add hooks for managing encrypted guest memory > KVM: selftests: handle encryption bits in page tables > KVM: selftests: set CPUID before setting sregs in vcpu creation > KVM: selftests: add support for encrypted vm_vaddr_* allocations > KVM: selftests: add library for creating/interacting with SEV guests > KVM: selftests: add SEV boot tests > KVM: SVM: include CR3 in initial VMSA state for SEV-ES guests > KVM: selftests: account for error code in #VC exception frame > KVM: selftests: add support for creating SEV-ES guests > KVM: selftests: add library for handling SEV-ES-related exits > KVM: selftests: add SEV-ES boot tests > KVM: selftests: add support for creating SEV-SNP guests > KVM: selftests: add helpers for SEV-SNP-related instructions/exits > KVM: selftests: add SEV-SNP boot tests > KVM: selftests: add SEV-SNP tests for page-state changes > > arch/x86/include/asm/kvm-x86-ops.h | 1 + > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/svm/svm.c | 22 ++ > arch/x86/kvm/vmx/vmx.c | 8 + > arch/x86/kvm/x86.c | 3 +- > tools/testing/selftests/kvm/.gitignore | 2 + > tools/testing/selftests/kvm/Makefile | 3 + > tools/testing/selftests/kvm/include/kvm_util.h | 8 + > tools/testing/selftests/kvm/include/x86_64/sev.h | 70 ++++ > .../selftests/kvm/include/x86_64/sev_exitlib.h | 20 ++ > tools/testing/selftests/kvm/include/x86_64/svm.h | 35 ++ > .../selftests/kvm/include/x86_64/svm_util.h | 2 + > tools/testing/selftests/kvm/lib/kvm_util.c | 249 +++++++++----- > .../testing/selftests/kvm/lib/kvm_util_internal.h | 10 + > tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 +- > tools/testing/selftests/kvm/lib/x86_64/processor.c | 30 +- > tools/testing/selftests/kvm/lib/x86_64/sev.c | 381 +++++++++++++++++++++ > .../testing/selftests/kvm/lib/x86_64/sev_exitlib.c | 326 ++++++++++++++++++ > .../selftests/kvm/x86_64/sev_all_boot_test.c | 367 ++++++++++++++++++++ > .../selftests/kvm/x86_64/sev_snp_psc_test.c | 378 ++++++++++++++++++++ > 20 files changed, 1820 insertions(+), 100 deletions(-) > create mode 100644 tools/testing/selftests/kvm/include/x86_64/sev.h > create mode 100644 tools/testing/selftests/kvm/include/x86_64/sev_exitlib.h > create mode 100644 tools/testing/selftests/kvm/lib/x86_64/sev.c > create mode 100644 tools/testing/selftests/kvm/lib/x86_64/sev_exitlib.c > create mode 100644 tools/testing/selftests/kvm/x86_64/sev_all_boot_test.c > create mode 100644 tools/testing/selftests/kvm/x86_64/sev_snp_psc_test.c > > >