Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1415330rwl; Fri, 24 Mar 2023 10:10:56 -0700 (PDT) X-Google-Smtp-Source: AK7set8Q3K/0UeHOTwRzaTiRc7QyfwdcmTGpNolah1K0W/7vJZDLtzkPNrkJUlRIrk0WRAfBUWqf X-Received: by 2002:a05:6a20:4f9a:b0:d8:f061:abab with SMTP id gh26-20020a056a204f9a00b000d8f061ababmr3270119pzb.5.1679677855731; Fri, 24 Mar 2023 10:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679677855; cv=none; d=google.com; s=arc-20160816; b=jKlsKSjauD7MDfxWV1Oz72PlMk0YKDlcdVak6i7My0Smr+oIww8nIP3JI14DzdPfzX njHgAC1aMXz4ZiRkqJB+jRfzZX1pXIXClXttP1ARY7YEX/bJ4UqmmfsFuRV9esfMLY4H 547xnQXUcWK+gWsA4NFXKOg895/2B0JoUxqtM9n56QDNbrgujJF2D394d3Cc9YFo6MXL UcyzFuPsjVvIYcW0L3M+O8+0nWNCDSZQkJKaj2PkJmPsk8//XDdTdJfNCWwt9pWi5F2C A7jIS05+9dxm3m8HLe73Z3xu+uf+x+sTGBhZ0AgrKvgfGmONLjFvKzBJl04bhMLV70eI CnHA== 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:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=vyDS7zcExbdUJKL+EU4Z73G2mWyinpCTeuPFZtODKYE=; b=BIDaIE209+wOE/d1mjrDvwNcn+zljQ+Q/4S3+UHKo6PinDQK61MuNf6VhKxJjWQWM4 qLtSyyq/b4CJhGvFrKJ5+bPmQv5ojj0K8GkFlD8JobfdiLbqKGmmqHfUpFtTVrW7nPFr tFnG24htghXzAmZTOREEPeC/l4HXjQ9Vjo3rUuIdJvs+udJ1NQA+F6iHXlZoTe/0gNQq VNE1qQ+TWOIKA//HGWqRC5BLEGdIOFLnBPVFBkB3qthfiEIm+r1OVjYQJrLVGOrMujAy xo01ApCXPQpe1RMDDHplWzLH7u28CGN97mxBjW3m2gJt0fGxzZ/lhW8flje89P1Ss5JX MIMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="UOKFh/r2"; 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 u201-20020a6279d2000000b0062ae6345c66si2181029pfc.385.2023.03.24.10.10.42; Fri, 24 Mar 2023 10:10:55 -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="UOKFh/r2"; 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 S232002AbjCXRK2 (ORCPT + 99 others); Fri, 24 Mar 2023 13:10:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231992AbjCXRKX (ORCPT ); Fri, 24 Mar 2023 13:10:23 -0400 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 320EE21A38 for ; Fri, 24 Mar 2023 10:10:20 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id o89-20020a17090a0a6200b0023b3d3acdd6so2600463pjo.3 for ; Fri, 24 Mar 2023 10:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679677820; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vyDS7zcExbdUJKL+EU4Z73G2mWyinpCTeuPFZtODKYE=; b=UOKFh/r2A49LuZpNoYzxruwq0cUWLiB4ILV1YowxrZ7He1LO/2mMPJf7lfbKte7daz ah9gnQS7EOomNLly1ux0KwATpHwRt3vQy93XdyjUFTfKITsCoUhgZsTir+AKiGmjP7b4 +6wTYrEaegTyS9x+Rp6am1FdEFKYNdYZ6aYmR4WhmAU1C52iE2ZIV/GXql9yQRnfaGQ/ 6d4eISlWPolEpTEncTKagZmw7H8f11cs3/d7jCD8UlQQ0BNBArunAaLqEsVvhLVmElOQ ZBEdztZjZvtsm/GENWVZnqjiaor2zRr1Q2d4UDT63RGUbdWQHQgwY/RdPmhS+vfE8jWV yvig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679677820; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vyDS7zcExbdUJKL+EU4Z73G2mWyinpCTeuPFZtODKYE=; b=3EGlnw146s/FcQEgpqpBDndDmhb9skybv+wLR2T2iNdJkR2+gc/sf7hoEs/7c/HLzy 0dXmyl9oHxadmZpU1PSMP5BzqEap9tCNvSe6t2jYZjl+fB5Y5CV0IA1yhVbAsiI38X5Z 4LYdmXzLMS1J4X5TGHwuEl8TN/aO1yINz5eg753cGS6nefXShxxeLNsUuY+c8JYwqT+d QNS7D6X4/vfqMQplMrSgsSt3oI6JKhwvnfzNbtN4hl8fmXY9Fi/x7vjjrfnkM69g08HB k2dK1mcnlO/LsigF1rSyJgp3NQXBhALfjPUm0gd34wkBE1yG90pcSHynN9NSVbgEXOFA KxbQ== X-Gm-Message-State: AAQBX9egNUAFDfPZ29PE2DysCZNr/fe9/9eHufi1FntOt49u1qKTlhCK D/R0b1ma69gWBo5Rl9fX3jc7tD5sLXA= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:66cf:b0:23b:446b:bbfd with SMTP id z15-20020a17090a66cf00b0023b446bbbfdmr1097256pjl.1.1679677820315; Fri, 24 Mar 2023 10:10:20 -0700 (PDT) Date: Fri, 24 Mar 2023 10:10:18 -0700 In-Reply-To: <20230110175057.715453-3-pgonda@google.com> Mime-Version: 1.0 References: <20230110175057.715453-1-pgonda@google.com> <20230110175057.715453-3-pgonda@google.com> Message-ID: Subject: Re: [PATCH V6 2/7] KVM: selftests: add hooks for managing protected guest memory From: Sean Christopherson To: Peter Gonda Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Vishal Annapurve , Ackerley Tng , Andrew Jones , Michael Roth Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 On Tue, Jan 10, 2023, Peter Gonda wrote: > Add kvm_vm.protected metadata. Protected VMs memory, potentially > register and other state may not be accessible to KVM. This combined > with a new protected_phy_pages bitmap will allow the selftests to check > if a given pages is accessible. > > Cc: Paolo Bonzini > Cc: Sean Christopherson > Cc: Vishal Annapurve > Cc: Ackerley Tng > cc: Andrew Jones > Originally-by: Michael Roth > Signed-off-by: Peter Gonda > --- > .../selftests/kvm/include/kvm_util_base.h | 14 ++++++++++++-- > tools/testing/selftests/kvm/lib/kvm_util.c | 16 +++++++++++++--- > 2 files changed, 25 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h > index fbc2a79369b8..015b59a0b80e 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h > @@ -45,6 +45,7 @@ typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */ > struct userspace_mem_region { > struct kvm_userspace_memory_region region; > struct sparsebit *unused_phy_pages; > + struct sparsebit *protected_phy_pages; > int fd; > off_t offset; > enum vm_mem_backing_src_type backing_src_type; > @@ -111,6 +112,9 @@ struct kvm_vm { > vm_vaddr_t handlers; > uint32_t dirty_ring_size; > > + /* VM protection enabled: SEV, etc*/ > + bool protected; > + > /* Cache of information for binary stats interface */ > int stats_fd; > struct kvm_stats_header stats_header; > @@ -679,10 +683,16 @@ const char *exit_reason_str(unsigned int exit_reason); > > vm_paddr_t vm_phy_page_alloc(struct kvm_vm *vm, vm_paddr_t paddr_min, > uint32_t memslot); > -vm_paddr_t vm_phy_pages_alloc(struct kvm_vm *vm, size_t num, > - vm_paddr_t paddr_min, uint32_t memslot); > +vm_paddr_t _vm_phy_pages_alloc(struct kvm_vm *vm, size_t num, Two underscores please. Ignore the terrible precedent that has been set, we're slowly purging that crud. > + vm_paddr_t paddr_min, uint32_t memslot, bool protected); Wrap, no strong justification for running long in this case since the declaration has already wrapped, and the definition does wrap.