some code cleanup and fix for another edge case
This commit is contained in:
parent
0a2ccef4d3
commit
ede09f502b
@ -154,12 +154,16 @@ static void pc_init1(MachineState *machine,
|
|||||||
x86ms->below_4g_mem_size = lowmem;
|
x86ms->below_4g_mem_size = lowmem;
|
||||||
#ifdef QEMU_NYX
|
#ifdef QEMU_NYX
|
||||||
GET_GLOBAL_STATE()->mem_mapping_type = PC_PIIX_MEM_TYPE;
|
GET_GLOBAL_STATE()->mem_mapping_type = PC_PIIX_MEM_TYPE;
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_low = lowmem;
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_high = 0x100000000;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
x86ms->above_4g_mem_size = 0;
|
x86ms->above_4g_mem_size = 0;
|
||||||
x86ms->below_4g_mem_size = machine->ram_size;
|
x86ms->below_4g_mem_size = machine->ram_size;
|
||||||
#ifdef QEMU_NYX
|
#ifdef QEMU_NYX
|
||||||
GET_GLOBAL_STATE()->mem_mapping_type = PC_PIIX_MEM_LOW_TYPE;
|
GET_GLOBAL_STATE()->mem_mapping_type = PC_PIIX_MEM_TYPE;
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_low = lowmem;
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_high = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,14 +150,8 @@ static void pc_q35_init(MachineState *machine)
|
|||||||
*/
|
*/
|
||||||
if (machine->ram_size >= 0xb0000000) {
|
if (machine->ram_size >= 0xb0000000) {
|
||||||
lowmem = 0x80000000;
|
lowmem = 0x80000000;
|
||||||
#ifdef QEMU_NYX
|
|
||||||
GET_GLOBAL_STATE()->mem_mapping_type = Q35_MEM_MEM_TYPE;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
lowmem = 0xb0000000;
|
lowmem = 0xb0000000;
|
||||||
#ifdef QEMU_NYX
|
|
||||||
GET_GLOBAL_STATE()->mem_mapping_type = Q35_MEM_MEM_LOW_TYPE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the machine opt max-ram-below-4g. It is basically doing
|
/* Handle the machine opt max-ram-below-4g. It is basically doing
|
||||||
@ -181,9 +175,19 @@ static void pc_q35_init(MachineState *machine)
|
|||||||
if (machine->ram_size >= lowmem) {
|
if (machine->ram_size >= lowmem) {
|
||||||
x86ms->above_4g_mem_size = machine->ram_size - lowmem;
|
x86ms->above_4g_mem_size = machine->ram_size - lowmem;
|
||||||
x86ms->below_4g_mem_size = lowmem;
|
x86ms->below_4g_mem_size = lowmem;
|
||||||
|
#ifdef QEMU_NYX
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_type = Q35_MEM_MEM_TYPE;
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_low = lowmem;
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_high = 0x100000000;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
x86ms->above_4g_mem_size = 0;
|
x86ms->above_4g_mem_size = 0;
|
||||||
x86ms->below_4g_mem_size = machine->ram_size;
|
x86ms->below_4g_mem_size = machine->ram_size;
|
||||||
|
#ifdef QEMU_NYX
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_type = Q35_MEM_MEM_TYPE;
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_low = lowmem;
|
||||||
|
GET_GLOBAL_STATE()->mem_mapping_high = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xen_enabled()) {
|
if (xen_enabled()) {
|
||||||
|
@ -2,84 +2,40 @@
|
|||||||
#include "nyx/state/state.h"
|
#include "nyx/state/state.h"
|
||||||
#include "nyx/mem_split.h"
|
#include "nyx/mem_split.h"
|
||||||
|
|
||||||
#define PC_PIIX_LOW_MEM_SPLIT_START 0xe0000000
|
|
||||||
|
|
||||||
#define PC_PIIX_MEM_SPLIT_START 0x0C0000000
|
|
||||||
#define PC_PIXX_MEM_SPLIT_END 0x100000000
|
|
||||||
|
|
||||||
#define Q35_MEM_SPLIT_START 0x080000000
|
|
||||||
#define Q35_MEM_SPLIT_END 0x100000000
|
|
||||||
|
|
||||||
#define Q35_LOW_MEM_SPLIT_START 0x0b0000000
|
|
||||||
|
|
||||||
bool is_mem_mapping_supported(MemSplitType type){
|
bool is_mem_mapping_supported(MemSplitType type){
|
||||||
return type == PC_PIIX_MEM_LOW_TYPE || type == PC_PIIX_MEM_TYPE || type == Q35_MEM_MEM_LOW_TYPE || type == Q35_MEM_MEM_TYPE;
|
return GET_GLOBAL_STATE()->mem_mapping_type != MEM_SPLIT_TYPE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t get_mem_split_start(void){
|
uint64_t get_mem_split_start(void){
|
||||||
switch(GET_GLOBAL_STATE()->mem_mapping_type){
|
assert(is_mem_mapping_supported(GET_GLOBAL_STATE()->mem_mapping_type));
|
||||||
case PC_PIIX_MEM_LOW_TYPE:
|
return GET_GLOBAL_STATE()->mem_mapping_low;
|
||||||
return PC_PIIX_LOW_MEM_SPLIT_START;
|
|
||||||
case PC_PIIX_MEM_TYPE:
|
|
||||||
return PC_PIIX_MEM_SPLIT_START;
|
|
||||||
case Q35_MEM_MEM_LOW_TYPE:
|
|
||||||
return Q35_LOW_MEM_SPLIT_START;
|
|
||||||
case Q35_MEM_MEM_TYPE:
|
|
||||||
return Q35_MEM_SPLIT_START;
|
|
||||||
default:
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t get_mem_split_end(void){
|
uint64_t get_mem_split_end(void){
|
||||||
switch(GET_GLOBAL_STATE()->mem_mapping_type){
|
assert(is_mem_mapping_supported(GET_GLOBAL_STATE()->mem_mapping_type));
|
||||||
case PC_PIIX_MEM_TYPE:
|
assert(GET_GLOBAL_STATE()->mem_mapping_high != 0);
|
||||||
return PC_PIXX_MEM_SPLIT_END;
|
return GET_GLOBAL_STATE()->mem_mapping_high;
|
||||||
case Q35_MEM_MEM_TYPE:
|
|
||||||
return Q35_MEM_SPLIT_END;
|
|
||||||
default:
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t address_to_ram_offset(uint64_t offset){
|
uint64_t address_to_ram_offset(uint64_t offset){
|
||||||
switch(GET_GLOBAL_STATE()->mem_mapping_type){
|
assert(is_mem_mapping_supported(GET_GLOBAL_STATE()->mem_mapping_type));
|
||||||
case PC_PIIX_MEM_LOW_TYPE:
|
if(GET_GLOBAL_STATE()->mem_mapping_high == 0){
|
||||||
if(offset >= PC_PIIX_LOW_MEM_SPLIT_START){
|
assert(offset <= GET_GLOBAL_STATE()->mem_mapping_low);
|
||||||
abort();
|
|
||||||
}
|
|
||||||
return offset;
|
return offset;
|
||||||
case PC_PIIX_MEM_TYPE:
|
|
||||||
return offset >= PC_PIXX_MEM_SPLIT_END ? (offset - PC_PIXX_MEM_SPLIT_END) + PC_PIIX_MEM_SPLIT_START : offset;
|
|
||||||
case Q35_MEM_MEM_TYPE:
|
|
||||||
return offset >= Q35_MEM_SPLIT_END ? (offset - Q35_MEM_SPLIT_END) + Q35_MEM_SPLIT_START : offset;
|
|
||||||
case Q35_MEM_MEM_LOW_TYPE:
|
|
||||||
if(offset >= Q35_LOW_MEM_SPLIT_START){
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
return offset;
|
else{
|
||||||
default:
|
return offset >= GET_GLOBAL_STATE()->mem_mapping_high ? (offset - GET_GLOBAL_STATE()->mem_mapping_high) + GET_GLOBAL_STATE()->mem_mapping_low : offset;
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ram_offset_to_address(uint64_t offset){
|
uint64_t ram_offset_to_address(uint64_t offset){
|
||||||
switch(GET_GLOBAL_STATE()->mem_mapping_type){
|
|
||||||
case PC_PIIX_MEM_LOW_TYPE:
|
assert(is_mem_mapping_supported(GET_GLOBAL_STATE()->mem_mapping_type));
|
||||||
if(offset >= PC_PIIX_LOW_MEM_SPLIT_START){
|
if(GET_GLOBAL_STATE()->mem_mapping_high == 0){
|
||||||
abort();
|
assert(offset <= GET_GLOBAL_STATE()->mem_mapping_low);
|
||||||
}
|
|
||||||
return offset;
|
return offset;
|
||||||
case PC_PIIX_MEM_TYPE:
|
|
||||||
return offset >= PC_PIIX_MEM_SPLIT_START ? (offset - PC_PIIX_MEM_SPLIT_START) + PC_PIXX_MEM_SPLIT_END : offset;;
|
|
||||||
case Q35_MEM_MEM_TYPE:
|
|
||||||
return offset >= Q35_MEM_SPLIT_START ? (offset - Q35_MEM_SPLIT_START) + Q35_MEM_SPLIT_END : offset;
|
|
||||||
case Q35_MEM_MEM_LOW_TYPE:
|
|
||||||
if(offset >= Q35_LOW_MEM_SPLIT_START){
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
return offset;
|
else{
|
||||||
default:
|
return offset >= GET_GLOBAL_STATE()->mem_mapping_low ? (offset - GET_GLOBAL_STATE()->mem_mapping_low) + GET_GLOBAL_STATE()->mem_mapping_high : offset;
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,7 @@
|
|||||||
|
|
||||||
typedef enum MemSplitType {
|
typedef enum MemSplitType {
|
||||||
MEM_SPLIT_TYPE_INVALID,
|
MEM_SPLIT_TYPE_INVALID,
|
||||||
PC_PIIX_MEM_LOW_TYPE,
|
|
||||||
PC_PIIX_MEM_TYPE,
|
PC_PIIX_MEM_TYPE,
|
||||||
Q35_MEM_MEM_LOW_TYPE,
|
|
||||||
Q35_MEM_MEM_TYPE,
|
Q35_MEM_MEM_TYPE,
|
||||||
} MemSplitType;
|
} MemSplitType;
|
||||||
|
|
||||||
|
@ -120,7 +120,8 @@ void state_init_global(void)
|
|||||||
global_state.mem_mapping_type = MEM_SPLIT_TYPE_INVALID;
|
global_state.mem_mapping_type = MEM_SPLIT_TYPE_INVALID;
|
||||||
|
|
||||||
global_state.sharedir = sharedir_new();
|
global_state.sharedir = sharedir_new();
|
||||||
|
global_state.mem_mapping_low = 0;
|
||||||
|
global_state.mem_mapping_high = 0;
|
||||||
|
|
||||||
global_state.shared_bitmap_fd = 0;
|
global_state.shared_bitmap_fd = 0;
|
||||||
global_state.shared_bitmap_size = 0;
|
global_state.shared_bitmap_size = 0;
|
||||||
|
@ -139,6 +139,8 @@ typedef struct qemu_nyx_state_s {
|
|||||||
bool set_agent_config_done;
|
bool set_agent_config_done;
|
||||||
|
|
||||||
MemSplitType mem_mapping_type;
|
MemSplitType mem_mapping_type;
|
||||||
|
uint64_t mem_mapping_low;
|
||||||
|
uint64_t mem_mapping_high;
|
||||||
|
|
||||||
/* capabilites */
|
/* capabilites */
|
||||||
uint8_t cap_timeout_detection;
|
uint8_t cap_timeout_detection;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user