From nobody Mon May 6 12:48:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1630935764; cv=none; d=zohomail.com; s=zohoarc; b=etOov6AETIfND5tOPPM11LZEjgQ21agLy42DlqM6avfYLRj8JXW/Ehx1itQ8E6vGK+lMpdyYIgqb8gsbRW53Itv1j+GP+ziEjA3JOJYH9cqpVAVF5qd8tS7yYd5n4Sj4DxbW57ILTaGhUs7V+BE0FgfsJcFd9kJetIZb186pNb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630935764; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=1Op4eoAO59qaq+mkjX+eiujVM6Ur2TNXFe7+MnMWPAo=; b=XIUJKTuVbEt1VvahnL9VIZyj/ZdqKNKKSiH9mBGIllk41+lLBAxWdNaEXNiJvGr4A/Be/tAkj9X9CBk3odnkC4ZmEe770wQhvm+Uzr2lZb9dVI7iEjJSGHgg3AwldZR98MyOJDtmKedIbgWEzqF2GkXC5vmWBQrFKnTquKFHpfA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163093576451759.62529566145838; Mon, 6 Sep 2021 06:42:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.179932.326385 (Exim 4.92) (envelope-from ) id 1mNEtM-0002RE-9a; Mon, 06 Sep 2021 13:42:32 +0000 Received: by outflank-mailman (output) from mailman id 179932.326385; Mon, 06 Sep 2021 13:42:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNEtM-0002R7-6F; Mon, 06 Sep 2021 13:42:32 +0000 Received: by outflank-mailman (input) for mailman id 179932; Mon, 06 Sep 2021 13:42:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNEtL-0002Qv-PG for xen-devel@lists.xenproject.org; Mon, 06 Sep 2021 13:42:31 +0000 Received: from mail-lf1-x12c.google.com (unknown [2a00:1450:4864:20::12c]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6f9f0901-a3f0-434a-a066-225fbfd0f79f; Mon, 06 Sep 2021 13:42:30 +0000 (UTC) Received: by mail-lf1-x12c.google.com with SMTP id x27so13602366lfu.5 for ; Mon, 06 Sep 2021 06:42:30 -0700 (PDT) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id j20sm746556lfr.248.2021.09.06.06.42.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Sep 2021 06:42:29 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6f9f0901-a3f0-434a-a066-225fbfd0f79f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=1Op4eoAO59qaq+mkjX+eiujVM6Ur2TNXFe7+MnMWPAo=; b=h4C3JZ0PaIs5BAjfC12yjm/XbJG+Sg9p+OZEUfx6eyBgaJw16VkFji68h8VfPdxIED P6NK7acmk/yKEkPtyzd8dOEYML8uVsibT46B4+PTyLzRROJ9UOz50n3CKRTwqI4BtZID jYMegg7iXrsRGKkDxwGNXMUZtijc3jxaTR4SDPtzc6IhfF4/RKhw1B+8L7VqCWlFd72a Nw1aOjXB8yydiaSexP00VHw/XHaEC/OsrgKO90QMBaaRZ+NBjerGSvjiOcjwgLYsnxKN 41vUrRQsPxLno+ecJ+ts8wOK7MH7c+2sUWZ35uvbub1655t2VThcR2w8nj7iJLkWrbvY MJSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1Op4eoAO59qaq+mkjX+eiujVM6Ur2TNXFe7+MnMWPAo=; b=dtplSFlS2iLmP9mfCONq2rU9nXDXoRV8en7BPQgB1K1/Zv+kyugvTEITYW2gK0aExV p3Q3f1e7EijKTDTVroOH+KieAtV+vXNK2z/fZDc4J7/1cbEgjxS1J5BukQN9XCpFGn5s QrdPFq5EyeUXtSiKmVjcf1h4OVXRma9z2KwdmlpslhduhExOoWu76OaRcITbzYx0Kr3J 8zRxEJyKXxW6+jqMoeUqC5YGEcaaqarCiERgmvpgsewDBm6HGakr+kLUHgdM3nBhk2Mm Fm0+tWe0p6XlIIo0vZxhq1s2n8AlimIWcCdZoBk9Vwk+2t/D7NPnX87iHgiSFO4+jaTF B/vQ== X-Gm-Message-State: AOAM531Un2z+GEK1RiKtHeqDwJTLdhla0rIIqSE+iXiZn0EpbsY3p1fN HZn+ZUL71tL95iuM/3f99MZfyVyHbBY= X-Google-Smtp-Source: ABdhPJywLRGtr+1AwJ1jlC5wYfXjRpuRgZv/48wcKg6PKsZfGss8UwtlELHpiu/sosOoKvpQOWBbWQ== X-Received: by 2002:ac2:5f78:: with SMTP id c24mr2880538lfc.554.1630935749687; Mon, 06 Sep 2021 06:42:29 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Julien Grall Subject: [PATCH] xen/arm: optee: Allocate anonymous domheap pages Date: Mon, 6 Sep 2021 16:42:21 +0300 Message-Id: <1630935741-17088-1-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1630935765869100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko Allocate anonymous domheap pages as there is no strict need to account them to a particular domain. Since XSA-383 "xen/arm: Restrict the amount of memory that dom0less domU and dom0 can allocate" the dom0 cannot allocate memory outside of the pre-allocated region. This means if we try to allocate non-anonymous page to be accounted to dom0 we will get an over-allocation issue when assigning that page to the domain. The anonymous page, in turn, is not assigned to any domain. CC: Julien Grall Signed-off-by: Oleksandr Tyshchenko Acked-by: Volodymyr Babchuk Reviewed-by: Bertrand Marquis --- xen/arch/arm/tee/optee.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index 3453615..83b4994 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -410,7 +410,7 @@ static struct shm_rpc *allocate_and_pin_shm_rpc(struct = optee_domain *ctx, if ( !shm_rpc ) return ERR_PTR(-ENOMEM); =20 - shm_rpc->xen_arg_pg =3D alloc_domheap_page(current->domain, 0); + shm_rpc->xen_arg_pg =3D alloc_domheap_page(NULL, 0); if ( !shm_rpc->xen_arg_pg ) { xfree(shm_rpc); @@ -774,7 +774,7 @@ static int translate_noncontig(struct optee_domain *ctx, * - There is a plan to implement preemption in the code below, which * will allow use to increase default MAX_SHM_BUFFER_PG value. */ - xen_pgs =3D alloc_domheap_pages(current->domain, order, 0); + xen_pgs =3D alloc_domheap_pages(NULL, order, 0); if ( !xen_pgs ) return -ENOMEM; =20 @@ -938,7 +938,7 @@ static bool copy_std_request(struct cpu_user_regs *regs, =20 BUILD_BUG_ON(OPTEE_MSG_NONCONTIG_PAGE_SIZE > PAGE_SIZE); =20 - call->xen_arg_pg =3D alloc_domheap_page(current->domain, 0); + call->xen_arg_pg =3D alloc_domheap_page(NULL, 0); if ( !call->xen_arg_pg ) { set_user_reg(regs, 0, OPTEE_SMC_RETURN_ENOMEM); --=20 2.7.4