From mboxrd@z Thu Jan 1 00:00:00 1970 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 CE02EC433FE for ; Fri, 11 Nov 2022 01:42:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232365AbiKKBmy (ORCPT ); Thu, 10 Nov 2022 20:42:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231681AbiKKBmw (ORCPT ); Thu, 10 Nov 2022 20:42:52 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F9366315E for ; Thu, 10 Nov 2022 17:42:52 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id r10-20020a17090a1bca00b002137a500398so1988441pjr.5 for ; Thu, 10 Nov 2022 17:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=TAHihsTyfGyAOhGUW7I4wir9NV3xrHHtanIUEi5rljw=; b=ctVUY+NuP8bjPDhX7vuhDJvm2n25aX8oAUBCZdazRVXluVmP2yFQNgL+fjvTiAE9xc 4ynf3N8CCEFL5RljMwLCl3O5hJDYjH2EaLiXkOCV3+11QdPEv0794VY3V9S5THhl66FW nCNCPuFc/nfO+hwhcG8yOjc8CJw6yyeeJE72502RbwENwKbX7jcZtHlpMmGuy9L/QEwh SZU2FC2Aje8OKXZJUaym3TvV+tfZggBmCPaLSk7h+e0eLbUaspI5+4cnTbSltIJwgWDy jHAfK8k1GJgWseBKRl3xxDzuw03JbTtfuvFxL702lzXG/8BkQAEjuzlkLRknd2hNZIfA LjVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=TAHihsTyfGyAOhGUW7I4wir9NV3xrHHtanIUEi5rljw=; b=NjwdbYpdiNnJjbLumPh57KKEEEV8lUZ/NY0GETvOfVlUj5hVLmXMM6Wpu1Sx2M0U1L GLVZLmCUfRqUCNxPdgrGDSSQnA3ZdmMg7FymTTzZW6Eq/IyYHhKiZgzbBokiQx2e96tA GoD/8IyHmR3LPd9YYYdwGRRf+SK56qWI3Pa9QMgPzrevxaPgBw4OsP0YzjE1XVX5fUe6 qFwMzzxM8nzzZDFihO1nSYVlQFB+5xjY4eiWvJyRBoGiP1V3SfM5neNMTy95u+wMXqrO wdISi/u6GtiRF94kxf5R7aIDAYrZhFbaKJxTYY1jE6NklNX1FqipdyYpKNZq3XYvhFFS eyBg== X-Gm-Message-State: ANoB5pkQG1H3HM/yLRBsh0GV5se3WT2WetGwUvmkzWHNJV9wWuX4CMl0 AijQ1VzAZTtL+nZVJWUmVqqvS7+Ogo9zC7ux X-Google-Smtp-Source: AA0mqf52xLE3aMk5fS5x1WInkfim/45aB6RnUca127I+fO5id2BwMfEKoajVorUywyMwwNE39hKAh1Z0O/EkuHrJ X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a05:6a00:1581:b0:56b:d19f:33f8 with SMTP id u1-20020a056a00158100b0056bd19f33f8mr386838pfk.17.1668130971513; Thu, 10 Nov 2022 17:42:51 -0800 (PST) Date: Fri, 11 Nov 2022 01:42:38 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221111014244.1714148-1-vannapurve@google.com> Subject: [V1 PATCH 0/6] selftests: KVM: selftests for fd-based 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, 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, ackerleytng@google.com, Vishal Annapurve Content-Type: text/plain; charset="UTF-8" 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/20221109041358.GA118963@chaop.bj.intel.com/T/ Below changes aim to test the fd based approach for guest private memory in context of normal (non-confidential) VMs executing on non-confidential platforms. private_mem_test.c file adds selftest to access private memory from the guest via private/shared accesses and checking if the contents can be leaked to/accessed by vmm via shared memory view before/after conversions. Updates in V1 (Compared to RFC v3 patches): 1) Incorporated suggestions from Sean around simplifying KVM changes 2) Addressed comments from Sean 3) Added private mem test with shared memory backed by 2MB hugepages. RFC v3 series: https://lore.kernel.org/lkml/20220819174659.2427983-1-vannapurve@google.com/t/ This series has dependency on following patches: 1) V9 series patches from Chao mentioned above. Github link for the patches posted as part of this series: https://github.com/vishals4gh/linux/commits/priv_memfd_selftests-v1 Vishal Annapurve (6): KVM: x86: Add support for testing private memory KVM: Selftests: Add support for private memory KVM: selftests: x86: Add IS_ALIGNED/IS_PAGE_ALIGNED helpers KVM: selftests: x86: Execute VMs with private memory KVM: selftests: Add get_free_huge_2m_pages KVM: selftests: x86: Add selftest for private memory arch/x86/kvm/mmu/mmu.c | 4 + arch/x86/kvm/mmu/mmu_internal.h | 4 +- tools/testing/selftests/kvm/.gitignore | 1 + tools/testing/selftests/kvm/Makefile | 2 + .../selftests/kvm/include/kvm_util_base.h | 15 +- .../testing/selftests/kvm/include/test_util.h | 5 + .../kvm/include/x86_64/private_mem.h | 37 +++ .../selftests/kvm/include/x86_64/processor.h | 1 + tools/testing/selftests/kvm/lib/kvm_util.c | 58 ++++- tools/testing/selftests/kvm/lib/test_util.c | 30 +++ .../selftests/kvm/lib/x86_64/private_mem.c | 211 ++++++++++++++++++ .../selftests/kvm/x86_64/private_mem_test.c | 190 ++++++++++++++++ virt/kvm/Kconfig | 4 + virt/kvm/kvm_main.c | 2 +- 14 files changed, 555 insertions(+), 9 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/x86_64/private_mem.h create mode 100644 tools/testing/selftests/kvm/lib/x86_64/private_mem.c create mode 100644 tools/testing/selftests/kvm/x86_64/private_mem_test.c -- 2.38.1.431.g37b22c650d-goog