From: benjamin@sipsolutions.net
To: linux-um@lists.infradead.org
Cc: Benjamin Berg <benjamin.berg@intel.com>
Subject: [PATCH v3 1/5] um: Fix stub_start address calculation
Date: Wed, 12 Jun 2024 16:10:43 +0200 [thread overview]
Message-ID: <20240612141047.1633303-2-benjamin@sipsolutions.net> (raw)
In-Reply-To: <20240612141047.1633303-1-benjamin@sipsolutions.net>
From: Benjamin Berg <benjamin.berg@intel.com>
The calculation was wrong as it only subtracted one and then rounded
down for alignment. However, this is incorrect if host_task_size is not
already aligned.
This probably worked fine because on 64 bit the host_task_size is bigger
than returned by os_get_top_address.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
---
arch/um/kernel/um_arch.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index e95f805e5004..0d8b1a73cd5b 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -331,7 +331,8 @@ int __init linux_main(int argc, char **argv)
/* reserve a few pages for the stubs (taking care of data alignment) */
/* align the data portion */
BUILD_BUG_ON(!is_power_of_2(STUB_DATA_PAGES));
- stub_start = (host_task_size - 1) & ~(STUB_DATA_PAGES * PAGE_SIZE - 1);
+ stub_start = (host_task_size - STUB_DATA_PAGES * PAGE_SIZE) &
+ ~(STUB_DATA_PAGES * PAGE_SIZE - 1);
/* another page for the code portion */
stub_start -= PAGE_SIZE;
host_task_size = stub_start;
--
2.45.1
next prev parent reply other threads:[~2024-06-12 14:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 14:10 [PATCH v3 0/5] Increased address space for 64 bit benjamin
2024-06-12 14:10 ` benjamin [this message]
2024-06-12 14:10 ` [PATCH v3 2/5] um: Limit TASK_SIZE to the addressable range benjamin
2024-06-12 14:10 ` [PATCH v3 3/5] um: Do a double clone to disable rseq benjamin
2024-06-12 14:10 ` [PATCH v3 4/5] um: Discover host_task_size from envp benjamin
2024-06-12 14:10 ` [PATCH v3 5/5] um: Add 4 level page table support benjamin
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=20240612141047.1633303-2-benjamin@sipsolutions.net \
--to=benjamin@sipsolutions.net \
--cc=benjamin.berg@intel.com \
--cc=linux-um@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).