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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CA1EC433F5 for ; Tue, 19 Oct 2021 10:38:35 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E3EDC610E7 for ; Tue, 19 Oct 2021 10:38:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E3EDC610E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jsklnM0H4zEkJjNan0atiIlzR3j4zO0FBd2vHYbUPEA=; b=qt9G/miArldOOv SKsTjwqsSDO14y0/eolfQdK9r9MsipkCml59FdzHrnh8odpft/8nbz29LwYf7rbrr6vycvoYY3hox 5KkfNIFG0zfUjEn2ElJ+MLWVNzdofqMtDqSL1M92xWdzq4S+cDl3eLfcOmN0jFu1IwTdxdKRSg6gZ QlrIFeLGBF81gP/L2X8L8dIDHxtdrb/RS/atle3uWaNo/tIqAv6B7iixymU5f1PYAIO+wkFLU/OTw Dpz2oORZDlhVJUhxAcD6CedYsgVO4kRj/yS4AgFdCaxv8W95/cC99jd1intSr42BiZAm+ceN6RW4u t8W3EUuGKWZSU43kxU0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcmUf-000pqh-LQ; Tue, 19 Oct 2021 10:37:17 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcmUc-000ppa-1h for linux-arm-kernel@lists.infradead.org; Tue, 19 Oct 2021 10:37:15 +0000 Received: by mail-wr1-x435.google.com with SMTP id e12so46884048wra.4 for ; Tue, 19 Oct 2021 03:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FZvIm3rqsw9MtMgTyCQhjlomP50swDXOySBREOTm/vI=; b=lqYGu2It0lmJamUsz5mnal87KJQz57uMl5CRfvm+18bc0CrT5eJE8uEG4IZUc6pnlA 0sa+wUeQ53R1NMnsWdqyPTf2jltUrEtvss2u5/ih3XNjAlzXUyJaDlCgyUVnPvErq74f vL9rk/t1TV3G/Hds1jdViWa7qiwJT5HVmJkFCphsskZhjKZ5Tyu4gVEN61xP7ablAl9Z s9CFQ4xovQfHK78E7Ex3F96417dJdj95RCH9xZMUFW2r4dKqU5OKMTQBHZKkgIDjm7yK AhIJ6qHYOa8jtn1P1bt+NaN3tJPfyg4wE1/qN7DCSiASNquPcopCqr6Pm9P6vCeScyyP CFlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FZvIm3rqsw9MtMgTyCQhjlomP50swDXOySBREOTm/vI=; b=devbV//nxFx6xWv+ObtPI0YIeKtWpQvMZ6oB+UfP0O79WJcmfO+lRyoNqTW36Iq7EC W6QGJsUaVg0PKmAhU4LHnGIJ91/hvHwFu0d2/m8Gv9i9m+8oEsoHaqhHnYU3RpisSQxd PWP87/h5fBcs9QH1UeShKNTf4zqsuENFmvCAUv7J2LhwiOHInAvohSa31CdpZTw1SJap VzgGChj3G9kQ7B82R3+EQ+ZZGveERfb6mj7AjEQ3wwVkKVBNko8YGFSkLIHQqV9BSIuM GhmuJQkN1PPBhWeO/P5TYGMSBTZ6kilvwXfBUfzNUeMwJRlEKxwroU88XKAM+6Tsbiae 5KOQ== X-Gm-Message-State: AOAM531BHIWtsVQLhBNe0hoQ7XeaPny1yfPoEvpkbzWKPuG8SUxfcBew 1NDNkN2jQQbT8cbiihKKaT34sw== X-Google-Smtp-Source: ABdhPJyz22mwvAWldVTIrGk4wME1SD0IDfWLY0SLLrHbF7nyxwa1vm+zUEcoU6By6FC1N6CX2KlqsQ== X-Received: by 2002:adf:a2d7:: with SMTP id t23mr44228280wra.156.1634639830990; Tue, 19 Oct 2021 03:37:10 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:59ca:401f:83a8:de6d]) by smtp.gmail.com with ESMTPSA id n68sm1829366wmn.13.2021.10.19.03.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 03:37:10 -0700 (PDT) Date: Tue, 19 Oct 2021 11:37:08 +0100 From: Quentin Perret To: Andrew Walbran Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Fuad Tabba , David Brazdil , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Android Kernel Team Subject: Re: [PATCH 01/16] KVM: arm64: Introduce do_share() helper for memory sharing between components Message-ID: References: <20211013155831.943476-1-qperret@google.com> <20211013155831.943476-2-qperret@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211019_033714_152964_CCEB5C4F X-CRM114-Status: GOOD ( 18.70 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Andrew, On Friday 15 Oct 2021 at 16:11:49 (+0100), Andrew Walbran wrote: > On Wed, 13 Oct 2021 at 16:58, 'Quentin Perret' via kernel-team > > +struct pkvm_mem_transition { > > + u64 nr_pages; > > + > > + struct { > > + enum pkvm_component_id id; > > + u64 addr; > Is this the physical address or the IPA of the initiator? It would be > good to have a comment explaining. That's the address in the initiator's address space. For the host and guests that'll be an IPA (which also happens to be the same as the PA for the host) and for the hypervisor that'll be an EL2 VA. But yes, a comment won't hurt, so I'll add something. > > +static int check_share(struct pkvm_page_req *req, > > + struct pkvm_page_share_ack *ack, > > + struct pkvm_mem_share *share) > > +{ > > + if (!addr_is_memory(req->phys)) > > + return -EINVAL; > > + > > + if (req->initiator.state == PKVM_PAGE_OWNED && > > + ack->completer.state == PKVM_NOPAGE) { > > + return 0; > > + } > > + > > + if (req->initiator.state != PKVM_PAGE_SHARED_OWNED) > > + return -EPERM; > > + > > + if (ack->completer.state != PKVM_PAGE_SHARED_BORROWED) > > + return -EPERM; > > + > > + if (ack->completer.phys != req->phys) > > + return -EPERM; > > + > > + if (ack->completer.prot != share->prot) > > + return -EPERM; > I guess this is the workaround you mentioned for the fact that the > host can share the same page twice? It might be worth adding a comment > to explain that that's what's going on. Yep, that's what is going on here. But FWIW I'm currently reworking the way we refcount pages in v2, which will now become the host's responsibility. So, that should simplify things quite a bit at EL2, and make all of the above go away :-) Cheers, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel