From patchwork Fri Oct 28 08:34:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13023222 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6438ECAAA1 for ; Fri, 28 Oct 2022 08:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n+W2shD74eq1JOgCpEn99oFZ7OjHwLIu4KJmIGdbf98=; b=ngdputRepzFeVI cSHDUs9QyfUiB4pcrvf9U65FecKdq+zwj+WjRPMirPMUYuIhNDxQZj91jneixy8/GOmOnJv2L7gYA X8LhAqpNpyzeTCQ0/iMSY13uDs0bAXbaX8MhWntCBFnyl7Ec0EvsF+GcRuJMS9kIPClYcPhkBog0i wKBC8jM7sNS1UN5GtMwGEmLH5xonmRkdYnI/wyBI+nUSoRDOiPoSH6PKI2S4sxMDRI6jbs4zugI38 4TTUEsJmEQDPPB0wc2O3H5qN5NYJ7ZeO7SFXPgXZ50CIhoD84ZEl7R+8qXsJB6zHWo0EgG4aemcez 1vYs8hVUrlZW18LeDHiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooKpu-00G9oq-Ia; Fri, 28 Oct 2022 08:35:30 +0000 Received: from out2.migadu.com ([188.165.223.204]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooKpe-00G9kc-B5 for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 08:35:19 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1666946112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v7nGyF+ceJAPPHWcftx0juhP6HRqQm3ngJatvgO9sUI=; b=Gae7eGv2LwLyo+LbbLw0k0Ox6RF3/w4UaJkt2l0kvYN26ajznzk10KCzsxxwHkGO4DMkEb qgZpFVZXPkZvqlBRAtq//88V5LCuptcF0avbLXtWOyk7tMWSGQu+k+ZLKaGsp4HQNMYuzw Kuvvq+Mcysj4qMcYuZ8T7egAp4KqMYM= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Quentin Perret , kvmarm@lists.linux.dev, Will Deacon , Fuad Tabba , Vincent Donnefort , Oliver Upton Subject: [PATCH 1/2] KVM: arm64: Clean out the odd handling of completer_addr Date: Fri, 28 Oct 2022 08:34:47 +0000 Message-Id: <20221028083448.1998389-2-oliver.upton@linux.dev> In-Reply-To: <20221028083448.1998389-1-oliver.upton@linux.dev> References: <20221028083448.1998389-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_013514_687167_B1C39AA3 X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The layout of struct pkvm_mem_transition is a bit weird; the destination address for the transition is actually stashed in the initiator address context. Even weirder so, that address is thrown inside a union and return from helpers by use of an out pointer. Rip out the whole mess and move the destination address into the destination context sub-struct. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 70 ++++++++++----------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index 1e78acf9662e..3636a24e1b34 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -393,17 +393,12 @@ struct pkvm_mem_transition { enum pkvm_component_id id; /* Address in the initiator's address space */ u64 addr; - - union { - struct { - /* Address in the completer's address space */ - u64 completer_addr; - } host; - }; } initiator; struct { enum pkvm_component_id id; + /* Address in the completer's address space */ + u64 addr; } completer; }; @@ -471,43 +466,35 @@ static int __host_set_page_state_range(u64 addr, u64 size, return host_stage2_idmap_locked(addr, size, prot); } -static int host_request_owned_transition(u64 *completer_addr, - const struct pkvm_mem_transition *tx) +static int host_request_owned_transition(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; u64 addr = tx->initiator.addr; - *completer_addr = tx->initiator.host.completer_addr; return __host_check_page_state_range(addr, size, PKVM_PAGE_OWNED); } -static int host_request_unshare(u64 *completer_addr, - const struct pkvm_mem_transition *tx) +static int host_request_unshare(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; u64 addr = tx->initiator.addr; - *completer_addr = tx->initiator.host.completer_addr; return __host_check_page_state_range(addr, size, PKVM_PAGE_SHARED_OWNED); } -static int host_initiate_share(u64 *completer_addr, - const struct pkvm_mem_transition *tx) +static int host_initiate_share(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; u64 addr = tx->initiator.addr; - *completer_addr = tx->initiator.host.completer_addr; return __host_set_page_state_range(addr, size, PKVM_PAGE_SHARED_OWNED); } -static int host_initiate_unshare(u64 *completer_addr, - const struct pkvm_mem_transition *tx) +static int host_initiate_unshare(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; u64 addr = tx->initiator.addr; - *completer_addr = tx->initiator.host.completer_addr; return __host_set_page_state_range(addr, size, PKVM_PAGE_OWNED); } @@ -537,7 +524,7 @@ static bool __hyp_ack_skip_pgtable_check(const struct pkvm_mem_transition *tx) tx->initiator.id != PKVM_ID_HOST); } -static int hyp_ack_share(u64 addr, const struct pkvm_mem_transition *tx, +static int hyp_ack_share(const struct pkvm_mem_transition *tx, enum kvm_pgtable_prot perms) { u64 size = tx->nr_pages * PAGE_SIZE; @@ -548,34 +535,35 @@ static int hyp_ack_share(u64 addr, const struct pkvm_mem_transition *tx, if (__hyp_ack_skip_pgtable_check(tx)) return 0; - return __hyp_check_page_state_range(addr, size, PKVM_NOPAGE); + return __hyp_check_page_state_range(tx->completer.addr, size, PKVM_NOPAGE); } -static int hyp_ack_unshare(u64 addr, const struct pkvm_mem_transition *tx) +static int hyp_ack_unshare(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; if (__hyp_ack_skip_pgtable_check(tx)) return 0; - return __hyp_check_page_state_range(addr, size, + return __hyp_check_page_state_range(tx->completer.addr, size, PKVM_PAGE_SHARED_BORROWED); } -static int hyp_complete_share(u64 addr, const struct pkvm_mem_transition *tx, +static int hyp_complete_share(const struct pkvm_mem_transition *tx, enum kvm_pgtable_prot perms) { - void *start = (void *)addr, *end = start + (tx->nr_pages * PAGE_SIZE); + void *start = (void *)tx->completer.addr; + void *end = start + (tx->nr_pages * PAGE_SIZE); enum kvm_pgtable_prot prot; prot = pkvm_mkstate(perms, PKVM_PAGE_SHARED_BORROWED); return pkvm_create_mappings_locked(start, end, prot); } -static int hyp_complete_unshare(u64 addr, const struct pkvm_mem_transition *tx) +static int hyp_complete_unshare(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; - int ret = kvm_pgtable_hyp_unmap(&pkvm_pgtable, addr, size); + int ret = kvm_pgtable_hyp_unmap(&pkvm_pgtable, tx->completer.addr, size); return (ret != size) ? -EFAULT : 0; } @@ -583,12 +571,11 @@ static int hyp_complete_unshare(u64 addr, const struct pkvm_mem_transition *tx) static int check_share(struct pkvm_mem_share *share) { const struct pkvm_mem_transition *tx = &share->tx; - u64 completer_addr; int ret; switch (tx->initiator.id) { case PKVM_ID_HOST: - ret = host_request_owned_transition(&completer_addr, tx); + ret = host_request_owned_transition(tx); break; default: ret = -EINVAL; @@ -599,7 +586,7 @@ static int check_share(struct pkvm_mem_share *share) switch (tx->completer.id) { case PKVM_ID_HYP: - ret = hyp_ack_share(completer_addr, tx, share->completer_prot); + ret = hyp_ack_share(tx, share->completer_prot); break; default: ret = -EINVAL; @@ -611,12 +598,11 @@ static int check_share(struct pkvm_mem_share *share) static int __do_share(struct pkvm_mem_share *share) { const struct pkvm_mem_transition *tx = &share->tx; - u64 completer_addr; int ret; switch (tx->initiator.id) { case PKVM_ID_HOST: - ret = host_initiate_share(&completer_addr, tx); + ret = host_initiate_share(tx); break; default: ret = -EINVAL; @@ -627,7 +613,7 @@ static int __do_share(struct pkvm_mem_share *share) switch (tx->completer.id) { case PKVM_ID_HYP: - ret = hyp_complete_share(completer_addr, tx, share->completer_prot); + ret = hyp_complete_share(tx, share->completer_prot); break; default: ret = -EINVAL; @@ -659,12 +645,11 @@ static int do_share(struct pkvm_mem_share *share) static int check_unshare(struct pkvm_mem_share *share) { const struct pkvm_mem_transition *tx = &share->tx; - u64 completer_addr; int ret; switch (tx->initiator.id) { case PKVM_ID_HOST: - ret = host_request_unshare(&completer_addr, tx); + ret = host_request_unshare(tx); break; default: ret = -EINVAL; @@ -675,7 +660,7 @@ static int check_unshare(struct pkvm_mem_share *share) switch (tx->completer.id) { case PKVM_ID_HYP: - ret = hyp_ack_unshare(completer_addr, tx); + ret = hyp_ack_unshare(tx); break; default: ret = -EINVAL; @@ -687,12 +672,11 @@ static int check_unshare(struct pkvm_mem_share *share) static int __do_unshare(struct pkvm_mem_share *share) { const struct pkvm_mem_transition *tx = &share->tx; - u64 completer_addr; int ret; switch (tx->initiator.id) { case PKVM_ID_HOST: - ret = host_initiate_unshare(&completer_addr, tx); + ret = host_initiate_unshare(tx); break; default: ret = -EINVAL; @@ -703,7 +687,7 @@ static int __do_unshare(struct pkvm_mem_share *share) switch (tx->completer.id) { case PKVM_ID_HYP: - ret = hyp_complete_unshare(completer_addr, tx); + ret = hyp_complete_unshare(tx); break; default: ret = -EINVAL; @@ -743,12 +727,10 @@ int __pkvm_host_share_hyp(u64 pfn) .initiator = { .id = PKVM_ID_HOST, .addr = host_addr, - .host = { - .completer_addr = hyp_addr, - }, }, .completer = { .id = PKVM_ID_HYP, + .addr = hyp_addr, }, }, .completer_prot = PAGE_HYP, @@ -776,12 +758,10 @@ int __pkvm_host_unshare_hyp(u64 pfn) .initiator = { .id = PKVM_ID_HOST, .addr = host_addr, - .host = { - .completer_addr = hyp_addr, - }, }, .completer = { .id = PKVM_ID_HYP, + .addr = hyp_addr, }, }, .completer_prot = PAGE_HYP, From patchwork Fri Oct 28 08:34:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13023227 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D12A4ECAAA1 for ; Fri, 28 Oct 2022 08:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qJsxL3AC8snyX2+JkW/fgKFwMkbnpEGL1ddNNThDXoY=; b=FJNcWG/FYoqD2c hIaDkqZtY1GM6xuoehL6HTr23TSF3k4dxs3oOqsQsVDFZgxd/MChXGpneTEhZuZ9kjjh1LJkQE5Bb FP6C3/tlqVdR+1U1Jg5kAJRJqoFzG6BNrwL/qFopgbhYLOKLWfksiZyhZXlGiprPgFTXUR/C1qw0y PxkkJn3teOVfDX0DRwByD45ShTdQP69Y1wvjan5GrmWCKsSubgNLKJ97WW7XqYO40NV5LJW4M4bpb QF/hu9adnDPtYaz+Q7n/RA/bOstGn/o8y1v89wONGgT9i21028b9DBqROfCauvHSZTkbUC8alipF4 zkQvDFr/4RVeTFKiAX3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooKq3-00G9qc-Qf; Fri, 28 Oct 2022 08:35:39 +0000 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooKpg-00G9lG-FB for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 08:35:19 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1666946115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zy0IA436iYEGUIQEIa25JubDREt90ASK4SizzIZvaHA=; b=xvKzvfZCa+ZOaJUaCX6iRYJx2EpKfZAD1RGadJ1ClDPQhPC0Sf69kiVIsMs77qnqDoCEcL DsAAxdwDncFFgrG9xsvfA2ypWhJ/g2kvoNka+PIZU0Eb2ZM5AcpGbnM8U0mUasBfoAG5Mp gn96QrcW2Ds0qFuKVUaI5Rp8wXaaHfA= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Quentin Perret , kvmarm@lists.linux.dev, Will Deacon , Fuad Tabba , Vincent Donnefort , Oliver Upton Subject: [PATCH 2/2] KVM: arm64: Redefine pKVM memory transitions in terms of source/target Date: Fri, 28 Oct 2022 08:34:48 +0000 Message-Id: <20221028083448.1998389-3-oliver.upton@linux.dev> In-Reply-To: <20221028083448.1998389-1-oliver.upton@linux.dev> References: <20221028083448.1998389-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_013516_823621_07783C49 X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Perhaps it is just me, but the 'initiator' and 'completer' terms are slightly confusing descriptors for the addresses involved in a memory transition. Apply a rename to instead describe memory transitions in terms of a source and target address. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 68 +++++++++++++-------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index 3636a24e1b34..3ea389a8166f 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -391,20 +391,20 @@ struct pkvm_mem_transition { struct { enum pkvm_component_id id; - /* Address in the initiator's address space */ + /* Address in the source's address space */ u64 addr; - } initiator; + } source; struct { enum pkvm_component_id id; - /* Address in the completer's address space */ + /* Address in the target's address space */ u64 addr; - } completer; + } target; }; struct pkvm_mem_share { const struct pkvm_mem_transition tx; - const enum kvm_pgtable_prot completer_prot; + const enum kvm_pgtable_prot target_prot; }; struct check_walk_data { @@ -469,7 +469,7 @@ static int __host_set_page_state_range(u64 addr, u64 size, static int host_request_owned_transition(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; - u64 addr = tx->initiator.addr; + u64 addr = tx->source.addr; return __host_check_page_state_range(addr, size, PKVM_PAGE_OWNED); } @@ -477,7 +477,7 @@ static int host_request_owned_transition(const struct pkvm_mem_transition *tx) static int host_request_unshare(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; - u64 addr = tx->initiator.addr; + u64 addr = tx->source.addr; return __host_check_page_state_range(addr, size, PKVM_PAGE_SHARED_OWNED); } @@ -485,7 +485,7 @@ static int host_request_unshare(const struct pkvm_mem_transition *tx) static int host_initiate_share(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; - u64 addr = tx->initiator.addr; + u64 addr = tx->source.addr; return __host_set_page_state_range(addr, size, PKVM_PAGE_SHARED_OWNED); } @@ -493,7 +493,7 @@ static int host_initiate_share(const struct pkvm_mem_transition *tx) static int host_initiate_unshare(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; - u64 addr = tx->initiator.addr; + u64 addr = tx->source.addr; return __host_set_page_state_range(addr, size, PKVM_PAGE_OWNED); } @@ -521,7 +521,7 @@ static int __hyp_check_page_state_range(u64 addr, u64 size, static bool __hyp_ack_skip_pgtable_check(const struct pkvm_mem_transition *tx) { return !(IS_ENABLED(CONFIG_NVHE_EL2_DEBUG) || - tx->initiator.id != PKVM_ID_HOST); + tx->source.id != PKVM_ID_HOST); } static int hyp_ack_share(const struct pkvm_mem_transition *tx, @@ -535,7 +535,7 @@ static int hyp_ack_share(const struct pkvm_mem_transition *tx, if (__hyp_ack_skip_pgtable_check(tx)) return 0; - return __hyp_check_page_state_range(tx->completer.addr, size, PKVM_NOPAGE); + return __hyp_check_page_state_range(tx->target.addr, size, PKVM_NOPAGE); } static int hyp_ack_unshare(const struct pkvm_mem_transition *tx) @@ -545,14 +545,14 @@ static int hyp_ack_unshare(const struct pkvm_mem_transition *tx) if (__hyp_ack_skip_pgtable_check(tx)) return 0; - return __hyp_check_page_state_range(tx->completer.addr, size, + return __hyp_check_page_state_range(tx->target.addr, size, PKVM_PAGE_SHARED_BORROWED); } static int hyp_complete_share(const struct pkvm_mem_transition *tx, enum kvm_pgtable_prot perms) { - void *start = (void *)tx->completer.addr; + void *start = (void *)tx->target.addr; void *end = start + (tx->nr_pages * PAGE_SIZE); enum kvm_pgtable_prot prot; @@ -563,7 +563,7 @@ static int hyp_complete_share(const struct pkvm_mem_transition *tx, static int hyp_complete_unshare(const struct pkvm_mem_transition *tx) { u64 size = tx->nr_pages * PAGE_SIZE; - int ret = kvm_pgtable_hyp_unmap(&pkvm_pgtable, tx->completer.addr, size); + int ret = kvm_pgtable_hyp_unmap(&pkvm_pgtable, tx->target.addr, size); return (ret != size) ? -EFAULT : 0; } @@ -573,7 +573,7 @@ static int check_share(struct pkvm_mem_share *share) const struct pkvm_mem_transition *tx = &share->tx; int ret; - switch (tx->initiator.id) { + switch (tx->source.id) { case PKVM_ID_HOST: ret = host_request_owned_transition(tx); break; @@ -584,9 +584,9 @@ static int check_share(struct pkvm_mem_share *share) if (ret) return ret; - switch (tx->completer.id) { + switch (tx->target.id) { case PKVM_ID_HYP: - ret = hyp_ack_share(tx, share->completer_prot); + ret = hyp_ack_share(tx, share->target_prot); break; default: ret = -EINVAL; @@ -600,7 +600,7 @@ static int __do_share(struct pkvm_mem_share *share) const struct pkvm_mem_transition *tx = &share->tx; int ret; - switch (tx->initiator.id) { + switch (tx->source.id) { case PKVM_ID_HOST: ret = host_initiate_share(tx); break; @@ -611,9 +611,9 @@ static int __do_share(struct pkvm_mem_share *share) if (ret) return ret; - switch (tx->completer.id) { + switch (tx->target.id) { case PKVM_ID_HYP: - ret = hyp_complete_share(tx, share->completer_prot); + ret = hyp_complete_share(tx, share->target_prot); break; default: ret = -EINVAL; @@ -628,8 +628,8 @@ static int __do_share(struct pkvm_mem_share *share) * The page owner grants access to another component with a given set * of permissions. * - * Initiator: OWNED => SHARED_OWNED - * Completer: NOPAGE => SHARED_BORROWED + * Source: OWNED => SHARED_OWNED + * Target: NOPAGE => SHARED_BORROWED */ static int do_share(struct pkvm_mem_share *share) { @@ -647,7 +647,7 @@ static int check_unshare(struct pkvm_mem_share *share) const struct pkvm_mem_transition *tx = &share->tx; int ret; - switch (tx->initiator.id) { + switch (tx->source.id) { case PKVM_ID_HOST: ret = host_request_unshare(tx); break; @@ -658,7 +658,7 @@ static int check_unshare(struct pkvm_mem_share *share) if (ret) return ret; - switch (tx->completer.id) { + switch (tx->target.id) { case PKVM_ID_HYP: ret = hyp_ack_unshare(tx); break; @@ -674,7 +674,7 @@ static int __do_unshare(struct pkvm_mem_share *share) const struct pkvm_mem_transition *tx = &share->tx; int ret; - switch (tx->initiator.id) { + switch (tx->source.id) { case PKVM_ID_HOST: ret = host_initiate_unshare(tx); break; @@ -685,7 +685,7 @@ static int __do_unshare(struct pkvm_mem_share *share) if (ret) return ret; - switch (tx->completer.id) { + switch (tx->target.id) { case PKVM_ID_HYP: ret = hyp_complete_unshare(tx); break; @@ -702,8 +702,8 @@ static int __do_unshare(struct pkvm_mem_share *share) * The page owner revokes access from another component for a range of * pages which were previously shared using do_share(). * - * Initiator: SHARED_OWNED => OWNED - * Completer: SHARED_BORROWED => NOPAGE + * Source: SHARED_OWNED => OWNED + * Target: SHARED_BORROWED => NOPAGE */ static int do_unshare(struct pkvm_mem_share *share) { @@ -724,16 +724,16 @@ int __pkvm_host_share_hyp(u64 pfn) struct pkvm_mem_share share = { .tx = { .nr_pages = 1, - .initiator = { + .source = { .id = PKVM_ID_HOST, .addr = host_addr, }, - .completer = { + .target = { .id = PKVM_ID_HYP, .addr = hyp_addr, }, }, - .completer_prot = PAGE_HYP, + .target_prot = PAGE_HYP, }; host_lock_component(); @@ -755,16 +755,16 @@ int __pkvm_host_unshare_hyp(u64 pfn) struct pkvm_mem_share share = { .tx = { .nr_pages = 1, - .initiator = { + .source = { .id = PKVM_ID_HOST, .addr = host_addr, }, - .completer = { + .target = { .id = PKVM_ID_HYP, .addr = hyp_addr, }, }, - .completer_prot = PAGE_HYP, + .target_prot = PAGE_HYP, }; host_lock_component();