Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3090345pxb; Mon, 18 Oct 2021 08:03:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzg9ezgNhibHeX7Mgdl5Qx5EqmsSQNEUfNIyT45V8db51GaSuQJADlaOuLy6bWe1UxY0whM X-Received: by 2002:a17:90b:368a:: with SMTP id mj10mr34598500pjb.201.1634569426660; Mon, 18 Oct 2021 08:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634569426; cv=none; d=google.com; s=arc-20160816; b=vZxQEATBpoXb0COeR1G1uaGgTAaO5T4BtHj9CV5p6+U94KEpUbqtsDaWU/UlMA52w9 X0mFTcE1oSY54qpMgcMNDTqZR3SLzX5Y/ozD9FeKTK9pW3LhqFUNm1ZBPiQZcTb7+gU+ VkNB0DSy99byC7nOw7qs77vo166pjbL3fidYfyeIfe7j5Cy+ImOj23vZmtwv3xizZQ8E KHqiTJQcoP1Cc/srSDymXJhg3FASoQZfgVQUsm2VaHVZJ08r5p/wQAFaaBOfXlomGHPE X/0uFw4BTSShhiJCqf+7cfuigDJJUjNEi1VZQ7buuVSh8ldaOExbFJRTGZMr+1xRHqLn /lCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yQkeMWxNdicFAAWTAtbOE6aF1W+WIaXoV/8+6cchqI8=; b=BqW7MQ2YYnItV0fGhpP+l/+xoFVgQqIP/wekNW591AYV/3tpH/zTFfH/bdvyzcLiXT wICOOM93ukYN6cMznK6PqBTvfwu6oqoH546Qg25FPOeVYjGdnzWo5v2xlSSjHkgDOgXj mpTh0RERgRaBIufanvEj2vW5Ys0fM4yFph2iQHIonN8akvk5eYoP2CwhfdUrxuCKinQP XM5VDPuh4UEJahenL4dTcmPqJJSBGBl1OmBm8OjbvgIYOrt1UXbfsWOn1U0kbFalBGAs 9J1oDa7BKp4A0g0yJK8R6lPBy3fOVHtXU6xtnEcAHrqbGGgRhhqF+rYanBf+vHATh2ux K8Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=HQuhjHzd; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ij16si21426558plb.195.2021.10.18.08.03.33; Mon, 18 Oct 2021 08:03:46 -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=@google.com header.s=20210112 header.b=HQuhjHzd; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233343AbhJRPDG (ORCPT + 99 others); Mon, 18 Oct 2021 11:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233258AbhJRPC6 (ORCPT ); Mon, 18 Oct 2021 11:02:58 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BB58C061770 for ; Mon, 18 Oct 2021 08:00:47 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id v195so1581803ybb.0 for ; Mon, 18 Oct 2021 08:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yQkeMWxNdicFAAWTAtbOE6aF1W+WIaXoV/8+6cchqI8=; b=HQuhjHzd68lT6lhxBf8HUihdVnwS4T2Ig7sWEvOoCGgH+ysNUMxEI3OkdpA0XJ74h0 +JbF74+ixWIP4aQ9aV+cZsR4mY7dUANs/zVo4qgrvzHBGLI8wpa07bQ+UixgKa75y/UO C8QKQboTm9rG3SZsGHsNXpR0TGfklavauhsf14OFmCnwBrzID3M9j5at+j75UpVCSx2D /fOfh3RfFDrqKLx9jnLqJOC/m5H7gypxMkx0a2L/mf0WAC4anpLHRrMTsz1nlizuu6Lt TCuvOEQtuoijHtNWIpS8evoR4GC97kOX1tr6sx8zqntbtS/+7+TmwBMzsdPBCiph2WF2 oDZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yQkeMWxNdicFAAWTAtbOE6aF1W+WIaXoV/8+6cchqI8=; b=va9rrjOGnV5ZccrNZ5hWFthneT0dA72qS9h7Hoy3y7djfpxwUZczjGaXmhqG7/JtZG GLS1u1A4vVC2qK5iQ/0QtjWkSw72yQUu5f9JAsJ0BYaGhoRtSIxCHlgw20rs/4iXxslq oLj21hr7h4qwx3uIviHsNRvDDyjj4qAsOkmwF56QfOzQGCgHJjwGhhHjup2WwRNBqYNg StSACOcns0SBQfGzAp/pw8NWUv/hCGWkn5Q4frjJaWtfEeivxmdGIQzfS00ZVgF5ey/3 G+mH7vyzmFWxsJDCxJkaFH0tqSmX2M+9wT2ugsD3+QkdYi7563xUQr31EAl6UylZGwzx Irtw== X-Gm-Message-State: AOAM532nMG8su6erzg4q0mAT55LBqr1KnrZ+FDKK70crrTTANhE3oV6T S4liOugLGkkiVslxSfaipjV7tpPSYyRbgXec7u3lKSctIHSI4w== X-Received: by 2002:a25:1487:: with SMTP id 129mr32454048ybu.206.1634569246414; Mon, 18 Oct 2021 08:00:46 -0700 (PDT) MIME-Version: 1.0 References: <20211005234459.430873-1-michael.roth@amd.com> <20211005234459.430873-3-michael.roth@amd.com> In-Reply-To: <20211005234459.430873-3-michael.roth@amd.com> From: Mingwei Zhang Date: Mon, 18 Oct 2021 08:00:00 -0700 Message-ID: Subject: Re: [RFC 02/16] KVM: selftests: add hooks for managing encrypted guest memory To: Michael Roth Cc: linux-kselftest@vger.kernel.org, kvm , LKML , x86@kernel.org, Nathan Tempelman , Marc Orr , Steve Rutherford , Sean Christopherson , 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" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +void vm_set_memory_encryption(struct kvm_vm *vm, bool enc_by_default, bool has_enc_bit, > + uint8_t enc_bit) > +{ > + vm->memcrypt.enabled = true; > + vm->memcrypt.enc_by_default = enc_by_default; > + vm->memcrypt.has_enc_bit = has_enc_bit; > + vm->memcrypt.enc_bit = enc_bit; > +} > + > +struct sparsebit * > +vm_get_encrypted_phy_pages(struct kvm_vm *vm, int slot, vm_paddr_t *gpa_start, > + uint64_t *size) > +{ > + struct userspace_mem_region *region; > + struct sparsebit *encrypted_phy_pages; > + > + if (!vm->memcrypt.enabled) > + return NULL; > + > + region = memslot2region(vm, slot); > + if (!region) > + return NULL; > + > + encrypted_phy_pages = sparsebit_alloc(); > + sparsebit_copy(encrypted_phy_pages, region->encrypted_phy_pages); Do we have to make a copy for the sparsebit? Why not just return the pointer? By looking at your subsequent patches, I find that this data structure seems to be just read-only? -Mingwei