Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Arm support #24

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open

Conversation

weizhou-chaojixx
Copy link

I have rebased all your current commits in master. By the way, since the CPU state struct of ARM has been dramatically changed from 1.0 to 3.0. And the QEMU client has to use some CPU state vars for interrupts. If I use VM exit to sync these var will make the VM exit too frequent, so I just sync these vars by writing 1.0 CPU state with the fixed offset of 3.0 state, which is ugly and will also lead the compiling warning. However, that is a more efficient and timely method. When you update libcpu from 1.0 to the 3.0 or 4.0. I will fix this problem.

src/cpu-exec.c Outdated
@@ -28,7 +28,7 @@

#define barrier() asm volatile("" ::: "memory")

// #define DEBUG_EXEC
#define DEBUG_EXEC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to disable it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in commit msg

@@ -234,7 +234,7 @@ DATA_TYPE glue(glue(io_read_chk, SUFFIX), MMUSUFFIX)(CPUArchState *env, target_p
res.res = glue(glue(io_read, SUFFIX), MMUSUFFIX)(env, origaddr, addr, retaddr);

end:
tcg_llvm_trace_mmio_access(addr, res.res, DATA_SIZE, 0);
res.res = tcg_llvm_trace_mmio_access(addr, res.res, DATA_SIZE, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is independent and should go into a separate PR.

@@ -174,7 +174,7 @@ static inline int _se_check_concrete(void *objectState, target_ulong offset, int
static inline void *_se_check_translate_ram_access(const void *p, unsigned size) {
#if defined(SE_ENABLE_PHYSRAM_TLB)
extern CPUArchState *env;
uintptr_t tlb_index = ((uintptr_t) p >> 12) & (CPU_TLB_SIZE - 1);
uintptr_t tlb_index = ((uintptr_t) p >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is independent and should go into a separate PR.

static inline int lduw_le_p(const void *ptr)
{
#ifdef _ARCH_PPC
int val;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S2E will probably never run on ARM hosts, so not sure if this is useful.

/* Load an instruction and return it in the standard little-endian order */
static inline uint32_t arm_ldl_code(uint32_t addr, bool do_swap) {
uint32_t insn = ldl_raw(addr);
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed commented-out code

src/bswap.h Outdated
@@ -267,7 +267,7 @@ typedef union {
} CPU_QuadU;

static inline int ldub_p(const void *ptr) {
return *(uint8_t *) ptr;
return *(uint8_t *) ptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run clang-format

@@ -67,6 +67,23 @@ struct kvm_regs {
unsigned long fiq_regs[8]; /* R8_fiq - R14_fiq, SPSR_fiq */
};

struct kvm_m_regs {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit msg should be prefixed with cpu/arm:...

#define KVM_GET_M_SREGS _IOR(KVMIO, 0xc2, struct kvm_m_sregs)
#define KVM_SET_M_SREGS _IOW(KVMIO, 0xc3, struct kvm_m_sregs)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many blank lines

@@ -266,7 +266,7 @@ static uintptr_t fetch_and_run_tb(TranslationBlock *prev_tb, int tb_exit_code, C
(uint64_t) env->eip, (uint64_t) env->eip + tb->size, (uint64_t) env->mflags,
env->kvm_request_interrupt_window);
#elif defined(TARGET_ARM)
DPRINTF(" fetch_and_run_tb r15=0x%x sp=0x%x cpsr=0x%x \n", (uint32_t) env->regs[15], env->regs[13], env->uncached_cpsr);
DPRINTF(" fetch_and_run_tb pc=0x%x sp=0x%x cpsr=0x%x \n", (uint32_t) env->regs[15], env->regs[13], env->uncached_cpsr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash this commit with the one that introduced the change.
There shouldn't be commits that fix previous commits in the same PR.

@@ -21,7 +21,7 @@

#include <cpu/config.h>

#if defined(TARGET_I386)
#if defined(TARGET_I386) || defined(TARGET_X86_64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? AFAIK, TARGET_X86_64 implies TARGET_I386.
In anycase, this should be sent to a separate PR.

@@ -504,7 +504,7 @@ static bool execution_loop(CPUArchState *env) {
* ensure that no TB jump will be modified as
* the program flow was changed
*/
last_tb = 0;
ltb = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate PR.

@@ -160,17 +160,20 @@ DATA_TYPE glue(glue(io_read, SUFFIX), MMUSUFFIX)(CPUArchState *env, target_phys_

SE_SET_MEM_IO_VADDR(env, addr, 0);

if (likely(!g_sqi.mem.is_mmio_symbolic(addr, DATA_SIZE))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you would still need to call the original handler for concolic execution (you need the original concrete value).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit could be sent to a separate PR

@weizhou-chaojixx weizhou-chaojixx force-pushed the arm-support branch 4 times, most recently from dd09349 to 1235ebb Compare January 13, 2020 04:53
@weizhou-chaojixx weizhou-chaojixx force-pushed the arm-support branch 5 times, most recently from 42dbf1a to 4e11a89 Compare January 20, 2020 22:33
Signed-off-by: chaojixx <wpz5080@psu.edu>
Signed-off-by: chaojixx <wpz5080@psu.edu>
replace ldxx_raw with ldxx_code

Signed-off-by: chaojixx <wpz5080@psu.edu>
1.move interrupt exit one DBT round in advance
2.when nvic update insert interrupt into cpu via arm_cpu_set_irq
3.only invoke interrupt when the prioity of current interrupt is lower than ready one

Signed-off-by: chaojixx <wpz5080@psu.edu>
Since the env pointer of kvm cpu (same as env->nvic->cpu) is different with tcg env, we let cpu_exit(env) when the sregs has been changed.
Note:now only exit when basepri reg has been changed.

Signed-off-by: chaojixx <wpz5080@psu.edu>
Signed-off-by: chaojixx <wpz5080@psu.edu>
Signed-off-by: chaojixx <wpz5080@psu.edu>
Signed-off-by: chaojixx <wpz5080@psu.edu>
Signed-off-by: chaojixx <wpz5080@psu.edu>
Signed-off-by: chaojixx <wpz5080@psu.edu>
…erface

Signed-off-by: chaojixx <wpz5080@psu.edu>
weizhou-chaojixx and others added 27 commits January 22, 2020 16:55
Exection mode switch needs to exit current execution loop. However, at that time the execution may not complete interrupt, so that will incur previous same interrupt again which should be avoided.

Signed-off-by: chaojixx <wpz5080@psu.edu>
regs in env struct may not be precise, so it should be replaced with cpu_R struct which refers to gen_bx_excret_final_code of qemu 3.0.0

Signed-off-by: chaojixx <wpz5080@psu.edu>
Signed-off-by: chaojixx <wpz5080@psu.edu>
…v struct may not be precise, so it should be replaced with cpu_R struct which refers to gen_bx_excret_final_code of qemu 3.0.0
Signed-off-by: chaojixx <wpz5080@psu.edu>
…v struct may not be precise, so it should be replaced with cpu_R struct which refers to gen_bx_excret_final_code of qemu 3.0.0
… not be frequently disrupted by interrupts

Signed-off-by: weizhou-chaojixx <wpz5080@psu.edu>
Signed-off-by: weizhou-chaojixx <wpz5080@psu.edu>
…on will not be frequently disrupted by interrupts
Signed-off-by: weizhou-chaojixx <wpz5080@psu.edu>
Signed-off-by: weizhou-chaojixx <wpz5080@psu.edu>
…on will not be frequently disrupted by interrupts
Signed-off-by: weizhou-chaojixx <wpz5080@psu.edu>
to make sure trigger and active is the same irq num

Signed-off-by: weizhou-chaojixx <wpz5080@psu.edu>
…on will not be frequently disrupted by interrupts
Signed-off-by: weizhou-chaojixx <wpz5080@psu.edu>
Signed-off-by: weizhou-chaojixx <wpz5080@psu.edu>
Signed-off-by: weizhou-chaojixx <weizhoulightning@gmail.com>
Signed-off-by: weizhou-chaojixx <weizhoulightning@gmail.com>
Signed-off-by: weizhou-chaojixx <weizhoulightning@gmail.com>
Signed-off-by: weizhou-chaojixx <weizhoulightning@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants