From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Next Mailing List <linux-next@vger.kernel.org>,
"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Steven Price <steven.price@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>
Subject: Re: linux-next: manual merge of the arm64 tree with the mm tree
Date: Wed, 20 Nov 2024 11:58:55 +1100 [thread overview]
Message-ID: <20241120115855.582867a7@canb.auug.org.au> (raw)
In-Reply-To: <20241024103709.082a6950@canb.auug.org.au>
[-- Attachment #1: Type: text/plain, Size: 3874 bytes --]
Hi all,
On Thu, 24 Oct 2024 10:37:09 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the arm64 tree got a conflict in:
>
> arch/arm64/mm/pageattr.c
>
> between commit:
>
> 040ee4186d6c ("arch: introduce set_direct_map_valid_noflush()")
>
> from the mm-unstable branch of the mm tree and commit:
>
> 42be24a4178f ("arm64: Enable memory encrypt for Realms")
>
> from the arm64 tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging. You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
>
> --
> Cheers,
> Stephen Rothwell
>
> diff --cc arch/arm64/mm/pageattr.c
> index 01225900293a,6ae6ae806454..000000000000
> --- a/arch/arm64/mm/pageattr.c
> +++ b/arch/arm64/mm/pageattr.c
> @@@ -192,16 -202,86 +202,96 @@@ int set_direct_map_default_noflush(stru
> PAGE_SIZE, change_page_range, &data);
> }
>
> +int set_direct_map_valid_noflush(struct page *page, unsigned nr, bool valid)
> +{
> + unsigned long addr = (unsigned long)page_address(page);
> +
> + if (!can_set_direct_map())
> + return 0;
> +
> + return set_memory_valid(addr, nr, valid);
> +}
> +
> + static int __set_memory_enc_dec(unsigned long addr,
> + int numpages,
> + bool encrypt)
> + {
> + unsigned long set_prot = 0, clear_prot = 0;
> + phys_addr_t start, end;
> + int ret;
> +
> + if (!is_realm_world())
> + return 0;
> +
> + if (!__is_lm_address(addr))
> + return -EINVAL;
> +
> + start = __virt_to_phys(addr);
> + end = start + numpages * PAGE_SIZE;
> +
> + if (encrypt)
> + clear_prot = PROT_NS_SHARED;
> + else
> + set_prot = PROT_NS_SHARED;
> +
> + /*
> + * Break the mapping before we make any changes to avoid stale TLB
> + * entries or Synchronous External Aborts caused by RIPAS_EMPTY
> + */
> + ret = __change_memory_common(addr, PAGE_SIZE * numpages,
> + __pgprot(set_prot),
> + __pgprot(clear_prot | PTE_VALID));
> +
> + if (ret)
> + return ret;
> +
> + if (encrypt)
> + ret = rsi_set_memory_range_protected(start, end);
> + else
> + ret = rsi_set_memory_range_shared(start, end);
> +
> + if (ret)
> + return ret;
> +
> + return __change_memory_common(addr, PAGE_SIZE * numpages,
> + __pgprot(PTE_VALID),
> + __pgprot(0));
> + }
> +
> + static int realm_set_memory_encrypted(unsigned long addr, int numpages)
> + {
> + int ret = __set_memory_enc_dec(addr, numpages, true);
> +
> + /*
> + * If the request to change state fails, then the only sensible cause
> + * of action for the caller is to leak the memory
> + */
> + WARN(ret, "Failed to encrypt memory, %d pages will be leaked",
> + numpages);
> +
> + return ret;
> + }
> +
> + static int realm_set_memory_decrypted(unsigned long addr, int numpages)
> + {
> + int ret = __set_memory_enc_dec(addr, numpages, false);
> +
> + WARN(ret, "Failed to decrypt memory, %d pages will be leaked",
> + numpages);
> +
> + return ret;
> + }
> +
> + static const struct arm64_mem_crypt_ops realm_crypt_ops = {
> + .encrypt = realm_set_memory_encrypted,
> + .decrypt = realm_set_memory_decrypted,
> + };
> +
> + int realm_register_memory_enc_ops(void)
> + {
> + return arm64_mem_crypt_ops_register(&realm_crypt_ops);
> + }
> +
> #ifdef CONFIG_DEBUG_PAGEALLOC
> void __kernel_map_pages(struct page *page, int numpages, int enable)
> {
This is now a conflict between the mm-stable tree and Linus' tree.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2024-11-20 0:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 23:37 Stephen Rothwell
2024-10-24 8:14 ` Catalin Marinas
2024-11-20 0:58 ` Stephen Rothwell [this message]
2024-10-28 0:10 Stephen Rothwell
2024-10-28 17:25 ` Catalin Marinas
2024-10-28 17:47 ` Suren Baghdasaryan
2024-11-20 1:01 ` Stephen Rothwell
2024-11-20 1:09 ` Suren Baghdasaryan
2024-11-20 1:43 ` Suren Baghdasaryan
2024-11-20 2:57 ` Stephen Rothwell
2024-11-20 3:18 ` Suren Baghdasaryan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241120115855.582867a7@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=rppt@kernel.org \
--cc=steven.price@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®