Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3161772ioo; Tue, 24 May 2022 14:51:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq6ydMDUchwI8JQu+TPzu2Q+IC3sTuxtZenElBcDqqcO1OIOjTVegxrZQfGcYJPIQk0sbH X-Received: by 2002:a17:902:bccc:b0:161:ffdb:b8e3 with SMTP id o12-20020a170902bccc00b00161ffdbb8e3mr19443142pls.113.1653429109293; Tue, 24 May 2022 14:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653429109; cv=none; d=google.com; s=arc-20160816; b=DSVzf9cajOFoycaOuGTw4Z/QOd1iPEnf9KLTP8cToA0zFquYMh0duianMiU8GcAowW xxgBAKNY2Nkn+/8C6LbGUMhKBeLqL75amufuwBNl+/V01/WBIcanyr1OqI0PtiHYx2dA /RAA/RR9UeDMrBq0c61giCxxZQeXvrJhsbkCHMqviV56nZkUCA6B34zqcAqxjI5k6eqk L32C9TkJGReJ7ZM71RuWrOIf3FG6rCHhFeu6e2kjJ1RM9cVw18ABNR9mYoRDZlD3yK/c /ndPhysGjn9h3yhXiXTBh4Nav/gcw1xXb3wJObg8/6N7dCDW3hqzHU2ZFy4GduVgD01M eifw== 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:mime-version:message-id:date :dkim-signature; bh=HEeApo5ALymfLav8MKuppOv54aHzpbE0xFgatZAbaOI=; b=tPhb9+k0bJdE6cREfjU676mJdfrmaca9oEdhGUuh9hUAURjXjWPAgSxEincS/7Hb1f dbsj4XjhfiPosIszwAGYC1VYmFQ4WOfLFMX2v3HmIH7G2wSrk2pRi64zoIydXvf3IZ3i cWlel26hzqP4Y+qgq54fK9ahH470tl7aLCsIUzqYCeNzcV3wJdmSAxth8aYpXLSUBtUK J1BU555TXWWqY4h7UK7tOx+5Wje4dofJI3GPDSsyyXde58iy56R8fIYLSyCxBGsgcrLi UASSfazny3Qdur+se7CP6pDEDI4WOrGTKgsgdaatw6DuT8B9NipyWQXLkJMI1s5fdGyR Msow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kv0qmQnm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a056a000b4400b0050fac0168c6si19241813pfo.49.2022.05.24.14.51.28; Tue, 24 May 2022 14:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kv0qmQnm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S241774AbiEXU5K (ORCPT + 99 others); Tue, 24 May 2022 16:57:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241164AbiEXU5D (ORCPT ); Tue, 24 May 2022 16:57:03 -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 B56A535843 for ; Tue, 24 May 2022 13:57:01 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id b9-20020a656689000000b003f672946300so6362052pgw.16 for ; Tue, 24 May 2022 13:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=HEeApo5ALymfLav8MKuppOv54aHzpbE0xFgatZAbaOI=; b=kv0qmQnmNTU7x7HQl/EE7lkTLtRc9F7QeG5hYPIFCg7DoOswX6ZjqlRK2L5bLUzTJq rmh1u/FAyYQ5xcZubP/gSjXLd8yenwWSBlpAZJli4lAa9w+k4BW57chK/Uu+LH9YXxY6 4yvJsFXJGxImE+cVVw4Fv5bqJsG9jFidqO/vrVqJ4sDfq2LIqV6ZL2tnO5rzLuaHlTj5 falYT0h/ngENNnyBIVR/7sxuZ7J61o/ZArK50y3skVrHvoie/eABFdeINJaL3D3/wHOM 5Y9ImSCkPczalysMqTzu8/WFixWASQnWYfvYaG7CJD2fJ2xaw3HJ5L9Has/SeubJpj/z B5AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=HEeApo5ALymfLav8MKuppOv54aHzpbE0xFgatZAbaOI=; b=kySDqKgq7MhKnEPfsRfEFqiR7HLDqCOx8mDM/yZruRJPxHWip59HYQV3XnM82LcGWI zczwv3Lpkcd4Mu0khbZoit3/Qv/A9/dl3Mde8gMOr/74SWpQwtqz9W55a9AkCaCO0l20 4ci1gKc2L2ZmCZbc6seIqLp/BNnwNlKVEmh4lDio/DwWrpmWl1yppGVUrZ/JKWbq/m5d q5GjVg2H+1mRcLNoxKt0bhS57XubZqot8rJTT8H714CdmovaflMjnpIMGULfHAv7rMbA 59Pj7twFYSrRyjuYClMoQpxIyZG4a/moF4tS/TSN9edOjroGSJmU/tXBYBJfc5PGMVFN un8g== X-Gm-Message-State: AOAM532J+CJ4KytMiymHIVgXFDqEe2aR0B7wHu1qOt/F4ti13LdVGU77 ftCv2t0goKA6w1tEVEPhIX8ZDZLEr8o3kQCY X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a05:6a00:1acb:b0:518:986c:a7c4 with SMTP id f11-20020a056a001acb00b00518986ca7c4mr13256588pfv.2.1653425821110; Tue, 24 May 2022 13:57:01 -0700 (PDT) Date: Tue, 24 May 2022 20:56:43 +0000 Message-Id: <20220524205646.1798325-1-vannapurve@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [RFC V1 PATCH 0/3] selftests: KVM: sev: selftests for fd-based approach of supporting private memory From: Vishal Annapurve To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: pbonzini@redhat.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, shuah@kernel.org, yang.zhong@intel.com, drjones@redhat.com, ricarkol@google.com, aaronlewis@google.com, wei.w.wang@intel.com, kirill.shutemov@linux.intel.com, corbet@lwn.net, hughd@google.com, jlayton@kernel.org, bfields@fieldses.org, akpm@linux-foundation.org, chao.p.peng@linux.intel.com, yu.c.zhang@linux.intel.com, jun.nakajima@intel.com, dave.hansen@intel.com, michael.roth@amd.com, qperret@google.com, steven.price@arm.com, ak@linux.intel.com, david@redhat.com, luto@kernel.org, vbabka@suse.cz, marcorr@google.com, erdemaktas@google.com, pgonda@google.com, nikunj@amd.com, seanjc@google.com, diviness@google.com, maz@kernel.org, dmatlack@google.com, axelrasmussen@google.com, maciej.szmigiero@oracle.com, mizhang@google.com, bgardon@google.com, Vishal Annapurve Content-Type: text/plain; charset="UTF-8" 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,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 This series implements selftests targeting the feature floated by Chao via: https://lore.kernel.org/linux-mm/20220519153713.819591-1-chao.p.peng@linux.intel.com/ Below changes aim to test the fd based approach for guest private memory in context of SEV/SEV-ES VMs executing on AMD SEV/SEV-ES compatible platforms. This series has dependency on following patch series: 1) V6 series patches from Chao mentioned above. 2) https://lore.kernel.org/all/20211210164620.11636-1-michael.roth@amd.com/T/ - KVM: selftests: Add support for test-selectable ucall implementations series by Michael Roth 3) https://lore.kernel.org/kvm/20220104234129.dvpv3o3tihvzsqcr@amd.com/T/ - KVM: selftests: Add tests for SEV and SEV-ES guests series by Michael Roth And few additional patches: * https://github.com/vishals4gh/linux/commit/2cb215cb6b4dff7fdf703498165179626c0cdfc7 - Confidential platforms along with the confidentiality aware software stack support a notion of private/shared accesses from the confidential VMs. Generally, a bit in the GPA conveys the shared/private-ness of the access. SEV/SEV-ES implementation doesn't expose the encryption bit information via fault address to KVM and so this hack is still needed to signal private/shared access ranges to the kvm. * https://github.com/vishals4gh/linux/commit/81a7d24231f6b8fb4174bbf97ed733688e8dbc0c Github link for the patches posted as part of this series: https://github.com/vishals4gh/linux/commits/sev_upm_selftests_rfc_v1 sev_priv_memfd_test.c file adds a suite of selftests to access private memory from the SEV/SEV-ES guests via private/shared accesses and checking if the contents can be leaked to/accessed by vmm via shared memory view. To allow SEV/SEV-ES VMs to toggle the encryption bit during memory conversion, support is added for mapping guest pagetables to guest va ranges and passing the mapping information to guests via shared pages. Vishal Annapurve (3): selftests: kvm: x86_64: Add support for pagetable tracking selftests: kvm: sev: Handle hypercall exit selftests: kvm: sev: Port UPM selftests onto SEV/SEV-ES VMs tools/testing/selftests/kvm/.gitignore | 1 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/kvm_util_base.h | 98 ++ tools/testing/selftests/kvm/lib/kvm_util.c | 81 +- .../selftests/kvm/lib/kvm_util_internal.h | 9 + .../selftests/kvm/lib/x86_64/processor.c | 36 + .../selftests/kvm/lib/x86_64/sev_exitlib.c | 39 +- .../kvm/x86_64/sev_priv_memfd_test.c | 1511 +++++++++++++++++ 8 files changed, 1770 insertions(+), 6 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/sev_priv_memfd_test.c -- 2.36.1.124.g0e6072fb45-goog