Capsule blocks step 1: the RAM block count is a build knob, BLK_RAM_USER_BLOCKS
Captain Bob ruled that the offset is the RAM block count, not a literal 2048. - v3/include/blk_layout.h defines it, 2048 by default. block_subsystem.h derives BLK_RAM_BLOCKS (2080) and BLK_DISK_START from it. - Kconfig.kernel has the symbol. kernel/Makefile passes it to the kernel's C code and builds mkcapsule and mkartemis with it. - mkcapsule's two literal 2048s are now the knob. The default value is unchanged, so the layout and the media are as before. Test first: scripts/test_capsule_ram_blocks.sh, 8 checks. - The before-run failed 4: the knob did not exist and mkcapsule ignored it. Its three Makefile checks also hit a SIGPIPE flaw in the test, fixed before the after-run. - After: all 8 pass. The amd64 build and mkartemis build clean. All 40 capsules lint. The mesh boot passes 109 checks with POST 990/990. test_host_blocks, test_host_quit, test_host_unit and test-32 pass. Logs are in logs/20261118-ram-blocks-knob. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
+10
-7
@@ -55,6 +55,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "blk_layout.h"
|
||||
#include "pkcs8_ed25519.h"
|
||||
#include "starkernel/ed25519.h"
|
||||
#include "starkernel/x509_ed25519.h"
|
||||
@@ -408,14 +409,16 @@ static int validate_forth_blocks(const char *fpath,
|
||||
block_num = (int)strtol((const char *)(data + start + 6), NULL, 10);
|
||||
line_in_block = 0;
|
||||
|
||||
/* Blocks 0..2047 are the VM's fast RAM and the only ones a
|
||||
* capsule may not claim; there is no upper bound
|
||||
* (docs/v4.0.0/NUCLEUS.md 5.2). */
|
||||
if (block_num < 2048) {
|
||||
/* Blocks 0 .. BLK_RAM_USER_BLOCKS - 1 are the VM's fast RAM and
|
||||
* the only ones a capsule page may not name: a page is copied
|
||||
* down by the RAM block count to be interpreted. The count is
|
||||
* the build's knob (blk_layout.h; capsule blocks plan, ruling 3),
|
||||
* not a literal; there is no upper bound. */
|
||||
if (block_num < (int)BLK_RAM_USER_BLOCKS) {
|
||||
fprintf(stderr,
|
||||
"mkcapsule: ERROR: %s:%d: block %d is in the VM's fast "
|
||||
"RAM (0..2047)\n",
|
||||
fpath, file_line, block_num);
|
||||
"RAM (0..%u)\n",
|
||||
fpath, file_line, block_num, (unsigned)BLK_RAM_USER_BLOCKS - 1u);
|
||||
errors++;
|
||||
}
|
||||
|
||||
@@ -1091,7 +1094,7 @@ static int blocks_free_at_delta(const int *blocks, int block_count, int delta,
|
||||
int skip_idx) {
|
||||
for (int j = 0; j < block_count; j++) {
|
||||
int candidate = blocks[j] + delta;
|
||||
if (candidate < 2048) return 0; /* system-reserved floor */
|
||||
if (candidate < (int)BLK_RAM_USER_BLOCKS) return 0; /* the VM's fast RAM: the build's knob (blk_layout.h) */
|
||||
if (reserved_owner_of(candidate)) return 0;
|
||||
for (int i = 0; i < manifest_count; i++) {
|
||||
if (i == skip_idx) continue;
|
||||
|
||||
Reference in New Issue
Block a user