nova: abandon hypervisor_info_page ROM

replace by platform_info ROM supposed to exist on all supported
kernels.

Fixes #2710
This commit is contained in:
Alexander Boettcher 2018-03-08 11:34:59 +01:00 committed by Christian Helmuth
parent 0fbd892b5c
commit 80e1dce1b0
10 changed files with 77 additions and 75 deletions

View File

@ -673,6 +673,16 @@ Platform::Platform() :
xml.attribute("pitch", boot_fb->aux);
});
});
xml.node("hardware", [&] () {
xml.node("features", [&] () {
xml.attribute("svm", hip->has_feature_svm());
xml.attribute("vmx", hip->has_feature_vmx());
});
xml.node("tsc", [&] () {
xml.attribute("invariant", cpuid_invariant_tsc());
xml.attribute("freq_khz" , hip->tsc_freq);
});
});
});
unmap_local(__main_thread_utcb, core_local_addr, pages);
@ -683,24 +693,6 @@ Platform::Platform() :
"platform_info"));
}
/* export hypervisor info page as ROM module */
{
void * phys_ptr = nullptr;
ram_alloc()->alloc_aligned(get_page_size(), &phys_ptr, get_page_size_log2());
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
addr_t const core_local_addr = _map_pages(phys_addr, 1);
memcpy(reinterpret_cast<void *>(core_local_addr), hip, get_page_size());
unmap_local(__main_thread_utcb, core_local_addr, 1);
region_alloc()->free(reinterpret_cast<void *>(core_local_addr), get_page_size());
_rom_fs.insert(new (core_mem_alloc())
Rom_module(phys_addr, get_page_size(),
"hypervisor_info_page"));
}
/* core log as ROM module */
{
void * phys_ptr = nullptr;

View File

@ -269,8 +269,9 @@ void test_revoke(Genode::Env &env)
void test_pat(Genode::Env &env)
{
/* read out the tsc frequenzy once */
Genode::Attached_rom_dataspace _ds(env, "hypervisor_info_page");
Nova::Hip * const hip = _ds.local_addr<Nova::Hip>();
Attached_rom_dataspace const platform_info (env, "platform_info");
Xml_node const hardware = platform_info.xml().sub_node("hardware");
uint64_t const tsc_freq = hardware.sub_node("tsc").attribute_value("freq_khz", 1ULL);
enum { DS_ORDER = 12, PAGE_4K = 12 };
@ -348,12 +349,12 @@ void test_pat(Genode::Env &env)
Trace::Timestamp diff_run = map_run > remap_run ? map_run - remap_run : remap_run - map_run;
if (check_pat && diff_run * 100 / hip->tsc_freq) {
if (check_pat && diff_run * 100 / tsc_freq) {
failed ++;
error("map=", Hex(map_run), " remap=", Hex(remap_run), " --> "
"diff=", Hex(diff_run), " freq_tsc=", hip->tsc_freq, " ",
diff_run * 1000 / hip->tsc_freq, " us");
"diff=", Hex(diff_run), " freq_tsc=", tsc_freq, " ",
diff_run * 1000 / tsc_freq, " us");
}
Nova::revoke(Nova::Mem_crd(remap_addr >> PAGE_4K, DS_ORDER, all));

View File

@ -622,7 +622,7 @@ append depot_deploy_config {
<start name="vm" pkg="} [depot_user]/pkg/[current_pkg vbox5-nova-sculpt] {">
<route>
<service name="ROM" label="capslock"> <parent label="capslock"/> </service>
<service name="ROM" label="hypervisor_info_page"> <parent/> </service>
<service name="ROM" label="platform_info"> <parent/> </service>
<service name="ROM" label="usb_devices"> <child name="usb_devices_rom"/> </service>
<service name="Report" label="shape"> <parent label="vm -> shape"/> </service>
<service name="Nitpicker"> <parent/> </service>

View File

@ -98,7 +98,7 @@
<service name="ROM" label_last="vimrc"> <parent/> </service>
<service name="ROM" label_last="slides.pdf"> <parent/> </service>
<service name="ROM" label_last="capslock"> <parent label="capslock"/> </service>
<service name="ROM" label_last="hypervisor_info_page"> <parent/> </service>
<service name="ROM" label_last="platform_info"> <parent/> </service>
<service name="ROM" label_last="wlan.config">
<parent label="config -> wlan.config"/> </service>
<service name="ROM" label="config"> <child name="report_rom"/> </service>

View File

@ -27,10 +27,11 @@ using namespace Nova;
Timer::Time_source::Time_source(Env &env) : Threaded_time_source(env)
{
/* read out the tsc frequenzy once */
Attached_rom_dataspace _ds(env, "hypervisor_info_page");
Nova::Hip * const hip = _ds.local_addr<Nova::Hip>();
_tsc_khz = hip->tsc_freq;
/* read out the tsc frequency once */
Attached_rom_dataspace const platform_info { env, "platform_info" };
Xml_node const hardware = platform_info.xml().sub_node("hardware");
hardware.sub_node("tsc").attribute("freq_khz").value(&_tsc_khz);
start();
}

View File

@ -24,8 +24,8 @@
<provides><service name="Timer"/></provides>
<config/>
<route>
<service name="ROM" label="hypervisor_info_page">
<parent label="hypervisor_info_page"/> </service>
<service name="ROM" label="platform_info">
<parent label="platform_info"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
@ -63,8 +63,8 @@
<service name="File_system"> <parent label="vm"/> </service>
<service name="ROM" label="usb_devices"> <parent label="usb_devices"/> </service>
<service name="ROM" label="capslock"> <parent label="capslock"/> </service>
<service name="ROM" label="hypervisor_info_page">
<parent label="hypervisor_info_page"/> </service>
<service name="ROM" label="platform_info">
<parent label="platform_info"/> </service>
<service name="Nic"> <parent/> </service>
<service name="Report" label="shape"> <parent label="shape"/> </service>
<any-service> <parent/> <child name="nit_fb"/> </any-service>

View File

@ -259,7 +259,7 @@ append_if $use_framebuffer config {
append_if $use_genode_iso config {
<service name="ROM" label="vm_seoul.cfg">
<parent/> </service>
<service name="ROM" label="hypervisor_info_page">
<service name="ROM" label="platform_info">
<parent/> </service>
<service name="ROM"><child name="iso9660"/></service>}
append config {

View File

@ -728,8 +728,6 @@ class Vcpu_dispatcher : public Vcpu_handler,
VCpu *unsynchronized_vcpu,
Guest_memory &guest_memory,
Synced_motherboard &motherboard,
bool has_svm,
bool has_vmx,
Vmm::Vcpu_thread *vcpu_thread,
Genode::Cpu_session *cpu_session,
Genode::Affinity::Location &location)
@ -748,6 +746,13 @@ class Vcpu_dispatcher : public Vcpu_handler,
Mtd const mtd_cpuid(Mtd::EIP | Mtd::ACDB | Mtd::IRQ);
Mtd const mtd_irq(Mtd::IRQ);
/* detect virtualization extension */
Attached_rom_dataspace const info(env, "platform_info");
Genode::Xml_node const features = info.xml().sub_node("hardware").sub_node("features");
bool const has_svm = features.attribute_value("svm", false);
bool const has_vmx = features.attribute_value("vmx", false);
/*
* Register vCPU event handlers
*/
@ -874,9 +879,7 @@ class Machine : public StaticReceiver<Machine>
Genode::Env &_env;
Genode::Heap &_heap;
Attached_rom_dataspace _hip_rom = { _env, "hypervisor_info_page" };
Genode::Cpu_connection _cpu_session = { _env, "Seoul vCPUs", Genode::Cpu_session::PRIORITY_LIMIT / 16 };
Hip * const _hip;
Clock _clock;
Genode::Lock _motherboard_lock;
Motherboard _unsynchronized_motherboard;
@ -981,16 +984,10 @@ class Machine : public StaticReceiver<Machine>
}
Vcpu_dispatcher *vcpu_dispatcher =
new Vcpu_dispatcher(_motherboard_lock,
_env,
msg.vcpu,
_guest_memory,
_motherboard,
_hip->has_feature_svm(),
_hip->has_feature_vmx(),
vcpu_thread,
&_cpu_session,
location);
new Vcpu_dispatcher(_motherboard_lock, _env,
msg.vcpu, _guest_memory,
_motherboard, vcpu_thread,
&_cpu_session, location);
msg.value = vcpu_dispatcher->sel_sm_ec();
return true;
@ -1240,10 +1237,9 @@ class Machine : public StaticReceiver<Machine>
Guest_memory &guest_memory, bool colocate)
:
_env(env), _heap(heap),
_hip(_hip_rom.local_addr<Hip>()),
_clock(_hip->tsc_freq*1000),
_clock(Attached_rom_dataspace(env, "platform_info").xml().sub_node("hardware").sub_node("tsc").attribute_value("freq_khz", 0ULL) * 1000ULL),
_motherboard_lock(Genode::Lock::LOCKED),
_unsynchronized_motherboard(&_clock, _hip),
_unsynchronized_motherboard(&_clock, nullptr),
_motherboard(_motherboard_lock, &_unsynchronized_motherboard),
_timeouts(_timeouts_lock, &_unsynchronized_timeouts),
_guest_memory(guest_memory),

View File

@ -65,21 +65,22 @@ static Vcpu_handler *lookup_vcpu_handler(unsigned int cpu_id)
/* Genode specific function */
Nova::Hip &hip_rom()
Genode::Xml_node platform_rom()
{
static Genode::Attached_rom_dataspace hip_rom(genode_env(),
"hypervisor_info_page");
return *hip_rom.local_addr<Nova::Hip>();
static Genode::Attached_rom_dataspace const platform(genode_env(),
"platform_info");
return platform.xml().sub_node("hardware");
}
void SUPR3QueryHWACCLonGenodeSupport(VM * pVM)
{
try {
pVM->hm.s.svm.fSupported = hip_rom().has_feature_svm();
pVM->hm.s.vmx.fSupported = hip_rom().has_feature_vmx();
Genode::Xml_node const features = platform_rom().sub_node("features");
pVM->hm.s.svm.fSupported = features.attribute_value("svm", false);
pVM->hm.s.vmx.fSupported = features.attribute_value("vmx", false);
if (hip_rom().has_feature_svm() || hip_rom().has_feature_vmx()) {
Genode::log("Using ", hip_rom().has_feature_svm() ? "SVM" : "VMX",
if (pVM->hm.s.svm.fSupported || pVM->hm.s.vmx.fSupported) {
Genode::log("Using ", pVM->hm.s.svm.fSupported ? "SVM" : "VMX",
" virtualization extension.");
return;
}
@ -195,7 +196,8 @@ uint64_t genode_cpu_hz()
if (!cpu_freq) {
try {
cpu_freq = hip_rom().tsc_freq * 1000;
platform_rom().sub_node("tsc").attribute("freq_khz").value(&cpu_freq);
cpu_freq *= 1000ULL;
} catch (...) {
Genode::error("could not read out CPU frequency");
Genode::Lock lock;
@ -290,20 +292,24 @@ bool create_emt_vcpu(pthread_t * pthread, size_t stack,
Genode::Affinity::Location location,
unsigned int cpu_id, const char * name)
{
if (!hip_rom().has_feature_vmx() && !hip_rom().has_feature_svm())
Genode::Xml_node const features = platform_rom().sub_node("features");
bool const svm = features.attribute_value("svm", false);
bool const vmx = features.attribute_value("vmx", false);
if (!svm && !vmx)
return false;
static Genode::Pd_connection pd_vcpus(genode_env(), "VM");
Vcpu_handler *vcpu_handler = 0;
if (hip_rom().has_feature_vmx())
if (vmx)
vcpu_handler = new (0x10) Vcpu_handler_vmx(genode_env(),
stack, attr, start_routine,
arg, cpu_session, location,
cpu_id, name, pd_vcpus);
if (hip_rom().has_feature_svm())
if (svm)
vcpu_handler = new (0x10) Vcpu_handler_svm(genode_env(),
stack, attr, start_routine,
arg, cpu_session, location,

View File

@ -180,22 +180,23 @@ HRESULT genode_setup_machine(ComObjPtr<Machine> machine)
/* Genode specific function */
Nova::Hip &hip_rom()
Genode::Xml_node platform_rom()
{
static Genode::Attached_rom_dataspace hip_rom(genode_env(),
"hypervisor_info_page");
return *hip_rom.local_addr<Nova::Hip>();
static Genode::Attached_rom_dataspace const platform(genode_env(),
"platform_info");
return platform.xml().sub_node("hardware");
}
void SUPR3QueryHWACCLonGenodeSupport(VM * pVM)
{
try {
pVM->hm.s.svm.fSupported = hip_rom().has_feature_svm();
pVM->hm.s.vmx.fSupported = hip_rom().has_feature_vmx();
Genode::Xml_node const features = platform_rom().sub_node("features");
pVM->hm.s.svm.fSupported = features.attribute_value("svm", false);
pVM->hm.s.vmx.fSupported = features.attribute_value("vmx", false);
if (hip_rom().has_feature_svm() || hip_rom().has_feature_vmx()) {
Genode::log("Using ", hip_rom().has_feature_svm() ? "SVM" : "VMX",
if (pVM->hm.s.svm.fSupported || pVM->hm.s.vmx.fSupported) {
Genode::log("Using ", pVM->hm.s.svm.fSupported ? "SVM" : "VMX",
" virtualization extension.");
return;
}
@ -690,7 +691,8 @@ uint64_t genode_cpu_hz()
if (!cpu_freq) {
try {
cpu_freq = hip_rom().tsc_freq * 1000;
platform_rom().sub_node("tsc").attribute("freq_khz").value(&cpu_freq);
cpu_freq *= 1000ULL;
} catch (...) {
Genode::error("could not read out CPU frequency");
Genode::Lock lock;
@ -776,20 +778,24 @@ bool create_emt_vcpu(pthread_t * pthread, ::size_t stack,
Genode::Affinity::Location location,
unsigned int cpu_id, const char * name)
{
if (!hip_rom().has_feature_vmx() && !hip_rom().has_feature_svm())
Genode::Xml_node const features = platform_rom().sub_node("features");
bool const svm = features.attribute_value("svm", false);
bool const vmx = features.attribute_value("vmx", false);
if (!svm && !vmx)
return false;
static Genode::Pd_connection pd_vcpus(genode_env(), "VM");
Vcpu_handler *vcpu_handler = 0;
if (hip_rom().has_feature_vmx())
if (vmx)
vcpu_handler = new (0x10) Vcpu_handler_vmx(genode_env(),
stack, attr, start_routine,
arg, cpu_session, location,
cpu_id, name, pd_vcpus);
if (hip_rom().has_feature_svm())
if (svm)
vcpu_handler = new (0x10) Vcpu_handler_svm(genode_env(),
stack, attr, start_routine,
arg, cpu_session, location,