Skip to content

Commit 5c91df0

Browse files
committed
components: gate CONFIG_PAGE_OFFSET page_offset pin on PAGE_OFFSET_FROM_CONFIG
boot_config and proc_config emitted CONFIG_PAGE_OFFSET as a REGION_PAGE_OFFSET base record, which page_offset_from_landmark pins to Q_PAGE_OFFSET via C_EQUALS — with no arch gate. CONFIG_PAGE_OFFSET equals the runtime page_offset only on PAGE_OFFSET_FROM_CONFIG arches (x86_32, arm32); on any arch whose CONFIG_PAGE_OFFSET differs from the running base, that pin would exclude the truth. (Latent today only because ppc, the one supported arch in that bucket, is PAGE_OFFSET_INVARIANT.) Gate both emissions on PAGE_OFFSET_FROM_CONFIG, mirroring the scalar path (bootconfig_facts -> page_offset_from_config). Gating, not removing: proc_config's /proc/config.gz is a source the scalar path does not read. Mark get_kconfig_page_offset __attribute__((unused)) since its call sites are now conditional.
1 parent 5971127 commit 5c91df0

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/components/boot_config.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,20 @@ int main(void) {
8888
if (open_boot_config(&fp) < 0)
8989
return KASLD_EXIT_UNAVAILABLE;
9090

91-
/* Detect PAGE_OFFSET (32-bit vmsplit) */
91+
#if PAGE_OFFSET_FROM_CONFIG
92+
/* Detect PAGE_OFFSET (32-bit vmsplit). CONFIG_PAGE_OFFSET equals the runtime
93+
* page_offset only on PAGE_OFFSET_FROM_CONFIG arches (x86_32, arm32); pinning
94+
* Q_PAGE_OFFSET to it via page_offset_from_landmark's C_EQUALS would exclude
95+
* the truth on arches whose CONFIG_PAGE_OFFSET differs from the running base.
96+
* (The properly gated scalar path is bootconfig_facts ->
97+
* page_offset_from_config.) */
9298
unsigned long virt_page_offset = get_kconfig_page_offset(fp);
9399
if (virt_page_offset) {
94100
kasld_info("CONFIG_PAGE_OFFSET: %#lx", virt_page_offset);
95101
kasld_result_base(KASLD_TYPE_VIRT, REGION_PAGE_OFFSET, virt_page_offset,
96102
NULL, CONF_PARSED);
97103
}
104+
#endif
98105

99106
/* CONFIG_PHYSICAL_START (x86 LOAD_PHYSICAL_ADDR). The honest-top floors
100107
* for Q_VIRT_IMAGE_BASE / Q_PHYS_IMAGE_BASE are *widened* to the smallest

src/components/proc_config.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,20 @@ int main(void) {
140140
if (!fp)
141141
return KASLD_EXIT_UNAVAILABLE;
142142

143-
/* Detect PAGE_OFFSET (32-bit vmsplit) */
143+
#if PAGE_OFFSET_FROM_CONFIG
144+
/* Detect PAGE_OFFSET (32-bit vmsplit). CONFIG_PAGE_OFFSET equals the runtime
145+
* page_offset only on PAGE_OFFSET_FROM_CONFIG arches (x86_32, arm32); pinning
146+
* Q_PAGE_OFFSET to it via page_offset_from_landmark's C_EQUALS would exclude
147+
* the truth on arches whose CONFIG_PAGE_OFFSET differs from the running base.
148+
* (The properly gated scalar path is bootconfig_facts ->
149+
* page_offset_from_config.) */
144150
unsigned long virt_page_offset = get_kconfig_page_offset(fp);
145151
if (virt_page_offset) {
146152
kasld_info("CONFIG_PAGE_OFFSET: %#lx", virt_page_offset);
147153
kasld_result_base(KASLD_TYPE_VIRT, REGION_PAGE_OFFSET, virt_page_offset,
148154
NULL, CONF_PARSED);
149155
}
156+
#endif
150157

151158
/* CONFIG_PHYSICAL_START (x86 LOAD_PHYSICAL_ADDR) — see boot_config.c. */
152159
unsigned long phys_start = get_kconfig_physical_start(fp);

src/include/kconfig.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ static int is_kconfig_set(FILE *fp, const char *config) {
3838

3939
/* Search for CONFIG_PAGE_OFFSET=0x... in the kernel config.
4040
* Falls back to CONFIG_VMSPLIT_* choices (x86_32, arm32).
41-
* Returns the value, or 0 if not found. */
42-
static unsigned long get_kconfig_page_offset(FILE *fp) {
41+
* Returns the value, or 0 if not found.
42+
* __attribute__((unused)): callers gate use on PAGE_OFFSET_FROM_CONFIG, so this
43+
* is unreferenced on arches where CONFIG_PAGE_OFFSET != runtime page_offset. */
44+
__attribute__((unused)) static unsigned long get_kconfig_page_offset(FILE *fp) {
4345
const char *key = "CONFIG_PAGE_OFFSET=";
4446
size_t keylen = strlen(key);
4547
char buf[BUFSIZ];

0 commit comments

Comments
 (0)