From patchwork Mon Feb 27 17:57:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13154049 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F2EEC7EE23 for ; Mon, 27 Feb 2023 17:58:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5EF186B00A8; Mon, 27 Feb 2023 12:57:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EA446B00A2; Mon, 27 Feb 2023 12:57:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C8506B00A2; Mon, 27 Feb 2023 12:57:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C60716B00A1 for ; Mon, 27 Feb 2023 12:57:52 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6E1BA140481 for ; Mon, 27 Feb 2023 17:57:52 +0000 (UTC) X-FDA: 80513829984.19.A1AED0D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id C271A160011 for ; Mon, 27 Feb 2023 17:57:49 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cb9QUN95; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677520669; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yM8cvfNz5jVfR0nEV77nAvQQBtTw5TotKep/NN0+z/U=; b=bP+3KvVDrIEoABCfJ9G1LhTDIJ1FfP7+7hLifP2u2C2st8pKjI2oHMQ8VM7n1L97SHdg4e jsxDv68bdwhwqhjmZ4OooFU+yuS8o9uCMgnfjaGZ1/SM3XfIPPc8f5flueSOkbTpqEvWOu kYAAz+Xv/PS727JBs3g4HoHjtwifdHA= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cb9QUN95; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677520669; a=rsa-sha256; cv=none; b=U6g+vGjXSyHpZyXnNYyr+ohXLP3JE/DYuY9mEH/WesgtqDRs8R1n5K81X5YQNr1Q6MEkH1 8PrvKU72yJ8UfXLubuV+ijXY0FEBcctrNo0PVNNJ8XPw1OEc7OBwGJfb8o+2byI7X5ijlO XvyrEFULgwXwofwgrOpXAhCBLpmZyy4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=yM8cvfNz5jVfR0nEV77nAvQQBtTw5TotKep/NN0+z/U=; b=cb9QUN95fkSR7nKcti6GhHyXtY 56DqsqF7zzmmEbqiLgEV80U+LGxfl+eESCShjFAAK90Ch1Z4gtgdWAsb+WD+X+VWBfghhL2BwEb3F GJGZASaY0IiF5HXZcytQN4HQ57z3o7N4+sTJT+G4DwqtxqoZIB2NKalce5TLzzCIdSt3JLfNP/Asm flBw6lItn8W4GpCaQ2phMC84kagXdG3ZRoqR9iGVewb9lc4MR8DEG4Id+sGp7gcDxdKCNlBqnu3FL TCj9fYtfVzARqg+Fh/pdMg2XkD/gNFg1uWXi0S+VO5D50h6LP7u7DXu3u8Dugq99HqqhnzWtvwL2A 1Ie4QEcA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWhku-000IXG-AG; Mon, 27 Feb 2023 17:57:44 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, linux-arch@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, Brian Cain Subject: [PATCH v2 09/30] hexagon: Implement the new page table range API Date: Mon, 27 Feb 2023 17:57:20 +0000 Message-Id: <20230227175741.71216-10-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230227175741.71216-1-willy@infradead.org> References: <20230227175741.71216-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C271A160011 X-Stat-Signature: jmnmmrej6y473hma8npdr8w3g43gn1ap X-HE-Tag: 1677520669-330009 X-HE-Meta: U2FsdGVkX19TLBWAc6d2IWgYfsy04iCrv34jUYjEeibt6YgSxca7iMmXykjcAuWwxxaUTVm6zoK8ex91ASyxFsBNdBkZ/YA7oJN2sIYhClRCCWmgWhl9AioBzw1EkLXoUtWyzUkTG/nnkb0jYPqUCO1wekCUypJg8INPflXHD+YZiSHP6RWxe5PD1Fy7q/sPaAuwNFPEEaObH4SwvrD4p/ixH/BkYSv1ncwtEwGADl3BW1lZrflQF7Jw+NFupQCwrZtHnpfBPTrKyvW2yQxnqatFz8J4HhRnehyO2ckx2vyy2sGsBJp3I+6F+tvAC01ng3MDWK8j+K2OkqHJrPpp/2LRTF1l1LdLw70/Y2rH94eJg6WaDVlaQwkKbsSRKFLgLDpyaM+9bsYerKvutOGVga+NuJhcS4B/NoWseccCg9x+RArkN5CLDCfhMasno1+XYlTddcFiHQlJ1pGk3SJrrQRr/17LVbh/nitc9hWkQ80fuQ+XhTTwuz5xmoQ07CIJ0x75g3Itwm6C8gb127VNHkMEYlay5FoM15neXiWQuH2/pvbN0EH+BINj333pqHQ0donYvdcyL6iS1VsEme8W7HQT8aLnIn3lPd4UV8H6UkqixC2NxvMDDXA69trZLLCQSGUkxP19ND+nETTXh1knJHSFjFaE+tSMPFOrtnTWViViUYq2GVS04W/m4tLWgZf9bzzncn2rtvk2ikfo/khuLGxoneCVMn6PC6iEevYkN3/B6no3eZJP6dAamfQ8QETUS2+FwsHQBrAm2sXy2kv9ardVc288WcPgBSs1Dbrr1LZC+waTRr7mb4hJRDU9IRH5VitJJBfyiGuuz+0si/7n1PpELCMbIFs+tmq8DCLlPqmYjLChLtH0elLBw8kI1Y+2F9vB9Q698lZNlL7Up2B6saDwm+abiy3sGaDBgrOI5LLSn5VkLuJP997IVmsdWnCbefmOYPddt1fLPxokHU2 9f4meEns lq5lker0VwKHHsSuKmu1G9OnH42lFQksLSdQSTC5ODA0Xmw4JpPqX0m88vcVmzSwhdosVLt9rzFG1kptICyvUtfqYdSdQEXIZXxtuCi7rf1R6/6OIzUMUBFLPbRMBbn+nn/BrqH8cCwNV4IeHGqrLOYhVvbaeWyz0Bl3cRgIBlug5eC5S9ezzPZTUG934Tw+ObbTTv9G1VECnhaSuTKExE8HT8BcRf801A4H/byJoOaG5y8r8bIpUdkkTSuXI+Ri/WHXx X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add set_ptes() and update_mmu_cache_range(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Brian Cain --- arch/hexagon/include/asm/cacheflush.h | 7 +++++-- arch/hexagon/include/asm/pgtable.h | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/hexagon/include/asm/cacheflush.h b/arch/hexagon/include/asm/cacheflush.h index 6eff0730e6ef..63ca314ede89 100644 --- a/arch/hexagon/include/asm/cacheflush.h +++ b/arch/hexagon/include/asm/cacheflush.h @@ -58,12 +58,15 @@ extern void flush_cache_all_hexagon(void); * clean the cache when the PTE is set. * */ -static inline void update_mmu_cache(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep) +static inline void update_mmu_cache_range(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep, unsigned int nr) { /* generic_ptrace_pokedata doesn't wind up here, does it? */ } +#define update_mmu_cache(vma, addr, ptep) \ + update_mmu_cache_range(vma, addr, ptep, 1) + void copy_to_user_page(struct vm_area_struct *vma, struct page *page, unsigned long vaddr, void *dst, void *src, int len); #define copy_to_user_page copy_to_user_page diff --git a/arch/hexagon/include/asm/pgtable.h b/arch/hexagon/include/asm/pgtable.h index 59393613d086..f58f1d920769 100644 --- a/arch/hexagon/include/asm/pgtable.h +++ b/arch/hexagon/include/asm/pgtable.h @@ -346,12 +346,24 @@ static inline int pte_exec(pte_t pte) #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval)) /* - * set_pte_at - update page table and do whatever magic may be + * set_ptes - update page table and do whatever magic may be * necessary to make the underlying hardware/firmware take note. * * VM may require a virtual instruction to alert the MMU. */ -#define set_pte_at(mm, addr, ptep, pte) set_pte(ptep, pte) +static inline void set_ptes(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned int nr) +{ + for (;;) { + set_pte(ptep, pte); + if (--nr == 0) + break; + ptep++; + pte_val(pte) += PAGE_SIZE; + } +} + +#define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1) static inline unsigned long pmd_page_vaddr(pmd_t pmd) {