Skip to content

Commit 17ca758

Browse files
authored
Merge pull request #1462 from fwsGonzo/dev
solo5: Add support for pre-BSS memory hole, fix start issue
2 parents 069c143 + 8c69784 commit 17ca758

4 files changed

Lines changed: 16 additions & 29 deletions

File tree

cmake/post.service.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,13 @@ if (${ELF} STREQUAL "i686")
223223
set(ELF "i386")
224224
endif()
225225

226+
set(PRE_BSS_SIZE "--defsym PRE_BSS_AREA=0x0")
227+
if ("${PLATFORM}" STREQUAL "x86_solo5")
228+
# pre-BSS memory hole for uKVM global variables
229+
set(PRE_BSS_SIZE "--defsym PRE_BSS_AREA=0x200000")
230+
endif()
226231

227-
set(LDFLAGS "-nostdlib -melf_${ELF} -N --eh-frame-hdr ${STRIP_LV} --script=${INSTALL_LOC}/${ARCH}/linker.ld ${INSTALL_LOC}/${ARCH}/lib/crtbegin.o")
232+
set(LDFLAGS "-nostdlib -melf_${ELF} -N --eh-frame-hdr ${STRIP_LV} --script=${INSTALL_LOC}/${ARCH}/linker.ld ${PRE_BSS_SIZE} ${INSTALL_LOC}/${ARCH}/lib/crtbegin.o")
228233

229234
set_target_properties(service PROPERTIES LINK_FLAGS "${LDFLAGS}")
230235

src/arch/x86_64/linker.ld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ SECTIONS
187187
LONG (0);
188188
}
189189

190+
/** Optional memory hole between memdisk and bss **/
191+
. += PRE_BSS_AREA;
192+
190193
.bss ALIGN(0x1000) :
191194
{
192195
_BSS_START_ = .;

src/platform/x86_solo5/kernel_start.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extern "C" {
6464

6565
// Initialize OS including devices
6666
OS::start(cmdline, mem_size);
67+
OS::post_start();
6768

6869
// Starting event loop from here allows us to profile OS::start
6970
OS::event_loop();

src/platform/x86_solo5/os.cpp

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -190,39 +190,17 @@ void OS::halt() {
190190
}
191191

192192
// Keep track of blocking levels
193-
static uint32_t* blocking_level = 0;
194-
static uint32_t* highest_blocking_level = 0;
195-
196-
197-
// Getters, mostly for testing
198-
extern "C" uint32_t os_get_blocking_level() {
199-
return *blocking_level;
200-
}
201-
extern "C" uint32_t os_get_highest_blocking_level() {
202-
return *highest_blocking_level;
203-
}
193+
static uint32_t blocking_level = 0;
194+
static uint32_t highest_blocking_level = 0;
204195

205196
void OS::block()
206197
{
207-
// Initialize stats
208-
if (not blocking_level) {
209-
blocking_level = &Statman::get()
210-
.create(Stat::UINT32, std::string("blocking.current_level")).get_uint32();
211-
*blocking_level = 0;
212-
}
213-
214-
if (not highest_blocking_level) {
215-
highest_blocking_level = &Statman::get()
216-
.create(Stat::UINT32, std::string("blocking.highest")).get_uint32();
217-
*highest_blocking_level = 0;
218-
}
219-
220198
// Increment level
221-
*blocking_level += 1;
199+
blocking_level += 1;
222200

223201
// Increment highest if applicable
224-
if (*blocking_level > *highest_blocking_level)
225-
*highest_blocking_level = *blocking_level;
202+
if (blocking_level > highest_blocking_level)
203+
highest_blocking_level = blocking_level;
226204

227205
int rc;
228206
rc = solo5_poll(solo5_clock_monotonic() + 50000ULL); // now + 0.05 ms
@@ -238,7 +216,7 @@ void OS::block()
238216
}
239217

240218
// Decrement level
241-
*blocking_level -= 1;
219+
blocking_level -= 1;
242220
}
243221

244222
extern "C"

0 commit comments

Comments
 (0)