From nobody Sun Feb 8 18:09:36 2026 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=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1596478961; cv=none; d=zohomail.com; s=zohoarc; b=XN8TOGfOCVPCZtsQCEbScGw6pOTN9VzGgoiKs5fRd/rBwx6hkdw9moP3bMFkz46b8Df02SwCtXbEeK5x/LW2DJcBY+/XxY4G4cWUwIHfww4Kj34NRV2I0FGOcZf0AjO23xyOm42WTlU31tKOXR19cjomB14xzcDP2aonEsZwIeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596478961; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=1oSrmefLumOTqH6DfN/w0NjDRHD49Q9D8VghKe2JYu8=; b=YajzwyPukLmj9p5ZQm15wHFb8f4T/Gsrbu8cUv4Uq7b+Qz4MFrLvJGpkbXUM/PHwq9wRFts9iD+JAtDSc6stklTh5dVkeHr1qYs9EO0E4b9mIAe13xySfUIlGkHE7IOOOGrcG4kc7KnkvIQf5RRSDbzyHGsrVF7JNr3rfCC2QHY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1596478961407550.2612619393415; Mon, 3 Aug 2020 11:22:41 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k2f6R-0008Rt-7Q; Mon, 03 Aug 2020 18:22:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k2f6Q-0008F4-7l for xen-devel@lists.xenproject.org; Mon, 03 Aug 2020 18:22:26 +0000 Received: from mail-lf1-x141.google.com (unknown [2a00:1450:4864:20::141]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 34f13356-d5b6-11ea-90c4-bc764e2007e4; Mon, 03 Aug 2020 18:21:54 +0000 (UTC) Received: by mail-lf1-x141.google.com with SMTP id x24so3651859lfe.11 for ; Mon, 03 Aug 2020 11:21:54 -0700 (PDT) Received: from otyshchenko.www.tendawifi.com ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id h18sm4486730ljk.7.2020.08.03.11.21.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2020 11:21:52 -0700 (PDT) X-Inumbo-ID: 34f13356-d5b6-11ea-90c4-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1oSrmefLumOTqH6DfN/w0NjDRHD49Q9D8VghKe2JYu8=; b=V//h+OxqeiTG5OZxMtbFbmVHdAJskjcYsEd2xBVHcfS3K60z84ELVyvw9UsE2OTKoV UGXy+Lkr2/oNp+UXmgZTECJ9QucYCQc7vn0fYfk8wB8WrfvyFeeM0qCFPuLvyonPNYbM 2aR6pdbUjRTh9dJ3By/wPCTtqD49tMntucBW3z8MfI33eAhL36GKjOw+NAyBmmQr/4Tn 0LfDyEag75/lUkYqunp4lJlPfXoQtAyOBzyL/qIBtzj/OggwyILcXnTdnHy2sg7THa+o sIfQcR+jow8oa6VJg//vmD5oY+75hRDzyu7zKKxmXPzNk6iVuVQGY6lAS3bILycYEDoP 5vEA== 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:in-reply-to :references; bh=1oSrmefLumOTqH6DfN/w0NjDRHD49Q9D8VghKe2JYu8=; b=Ap8qk2zJAKDGYOsOA33qUDPF+y3qEJBjMll6fcRqcB2nXoOp/Sy15w7Vfo9mN2yiy9 FB1raKhXu5UZoZkFs2qqQQxj+1QM1rP5AYKySnYzyzKneX5yaQaYueHvbhS3Kot2sGZA mA3+WyyDULzK+ERK5JP6QXeZI7x0wQsQEtmrK4aj8W1pfqqM6qQCouYUHrqT2b8VeTgI 19VFlv89yzu0Ws/sFn+wYoXWyJ/iAdMMCeXzi/mIRb2fR6NqffSXLnfZ7pLpv3skb9Kq ifsqF+udmHgmxzcyTpa1TOdUH1/MAzcueJOmdbslJyA0vDpTv51j+W7gzhIqv/thSRsk GV6g== X-Gm-Message-State: AOAM531hvV8mNb3fZaoSUYDQR321Fse+2d5mjpc4DYHEPn0Gmt+LRuPI THVS6SDnD0LwpPVPXnaMbp1El/imALs= X-Google-Smtp-Source: ABdhPJxm4yfX8MSfwMtCdpABV1bvZqTlKWi27x2GrGHTMWtxZu4TK/T5zajR7U42CXNf3f6RN1w07Q== X-Received: by 2002:a19:418a:: with SMTP id o132mr9319096lfa.63.1596478913112; Mon, 03 Aug 2020 11:21:53 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Subject: [RFC PATCH V1 08/12] xen/arm: Invalidate qemu mapcache on XENMEM_decrease_reservation Date: Mon, 3 Aug 2020 21:21:24 +0300 Message-Id: <1596478888-23030-9-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596478888-23030-1-git-send-email-olekstysh@gmail.com> References: <1596478888-23030-1-git-send-email-olekstysh@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Oleksandr Tyshchenko , Jan Beulich , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko Borrow x86's logic to invalidate qemu mapcache. TODO: Move send_invalidate_req() to common code (ioreq.c?). Signed-off-by: Oleksandr Tyshchenko --- xen/arch/arm/ioreq.c | 14 ++++++++++++++ xen/arch/arm/traps.c | 6 ++++++ xen/common/memory.c | 6 ++++++ xen/include/asm-arm/domain.h | 2 ++ xen/include/asm-arm/hvm/ioreq.h | 2 ++ 5 files changed, 30 insertions(+) diff --git a/xen/arch/arm/ioreq.c b/xen/arch/arm/ioreq.c index a9cc839..8f60c41 100644 --- a/xen/arch/arm/ioreq.c +++ b/xen/arch/arm/ioreq.c @@ -75,6 +75,20 @@ bool handle_mmio(void) return true; } =20 +/* Ask ioemu mapcache to invalidate mappings. */ +void send_invalidate_req(void) +{ + ioreq_t p =3D { + .type =3D IOREQ_TYPE_INVALIDATE, + .size =3D 4, + .dir =3D IOREQ_WRITE, + .data =3D ~0UL, /* flush all */ + }; + + if ( hvm_broadcast_ioreq(&p, false) !=3D 0 ) + gprintk(XENLOG_ERR, "Unsuccessful map-cache invalidate\n"); +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 4cdf098..ea472d1 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1490,6 +1490,12 @@ static void do_trap_hypercall(struct cpu_user_regs *= regs, register_t *nr, /* Ensure the hypercall trap instruction is re-executed. */ if ( current->hcall_preempted ) regs->pc -=3D 4; /* re-execute 'hvc #XEN_HYPERCALL_TAG' */ + +#ifdef CONFIG_IOREQ_SERVER + if ( unlikely(current->domain->arch.hvm.qemu_mapcache_invalidate) && + test_and_clear_bool(current->domain->arch.hvm.qemu_mapcache_inval= idate) ) + send_invalidate_req(); +#endif } =20 void arch_hypercall_tasklet_result(struct vcpu *v, long res) diff --git a/xen/common/memory.c b/xen/common/memory.c index 8b306f6..8d9f0a8 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -1652,6 +1652,12 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDL= E_PARAM(void) arg) break; } =20 + /* x86 already sets the flag in hvm_memory_op() */ +#if defined(CONFIG_ARM64) && defined(CONFIG_IOREQ_SERVER) + if ( op =3D=3D XENMEM_decrease_reservation ) + curr_d->arch.hvm.qemu_mapcache_invalidate =3D true; +#endif + return rc; } =20 diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index e060b0a..0db8bb4 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -69,6 +69,8 @@ struct hvm_domain spinlock_t lock; struct hvm_ioreq_server *server[MAX_NR_IOREQ_SERVERS]; } ioreq_server; + + bool_t qemu_mapcache_invalidate; }; =20 #ifdef CONFIG_ARM_64 diff --git a/xen/include/asm-arm/hvm/ioreq.h b/xen/include/asm-arm/hvm/iore= q.h index 83a560c..392ce64 100644 --- a/xen/include/asm-arm/hvm/ioreq.h +++ b/xen/include/asm-arm/hvm/ioreq.h @@ -90,6 +90,8 @@ static inline void arch_hvm_ioreq_destroy(struct domain *= d) #define IOREQ_IO_UNHANDLED IO_UNHANDLED #define IOREQ_IO_RETRY IO_RETRY =20 +void send_invalidate_req(void); + #endif /* __ASM_X86_HVM_IOREQ_H__ */ =20 /* --=20 2.7.4