Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.

Commit 2d7fa8b

Browse files
authored
Merge pull request #108 from kryptoslogic/linux
Added support for Linux hosts
2 parents e13a10e + f950759 commit 2d7fa8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2239
-56
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# macOS
22
.DS_Store
3+
4+
# Linux
5+
*.o
6+
*.cmd

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ matrix:
1313
- cd platforms/darwin
1414
- xcodebuild -configuration Debug -sdk macosx10.14
1515

16+
- name: "haxm-linux"
17+
os: linux
18+
dist: trusty
19+
sudo: false
20+
before_install:
21+
- sudo apt-get update
22+
- sudo apt-get install -y linux-headers-`uname -r`
23+
- wget http://mirrors.kernel.org/ubuntu/pool/universe/n/nasm/nasm_2.13.02-0.1_amd64.deb
24+
- sudo apt-get install -y dpkg
25+
- sudo dpkg -i nasm_2.13.02-0.1_amd64.deb
26+
script:
27+
- cd platforms/linux
28+
- make -j$(nproc)
29+
1630
exclude: # TODO: Currently TravisCI does not support full VS/EWDK on Windows
1731
- name: "haxm-windows"
1832
os: windows

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ release, you can get it [here][github-haxm-latest-release].
1313
## Usage
1414

1515
Detailed instructions for building and testing HAXM can be found at:
16+
* [Manual for Linux](docs/manual-linux.md)
1617
* [Manual for macOS](docs/manual-macos.md)
1718
* [Manual for Windows](docs/manual-windows.md)
1819

core/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ uint32_t load_vmcs(struct vcpu_t *vcpu, preempt_flag *flags)
520520
/* when wake up from sleep, we need the barrier, as vm operation
521521
* are not serialized instructions.
522522
*/
523-
smp_mb();
523+
hax_smp_mb();
524524

525525
cpu_data = current_cpu_data();
526526

core/ept.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static void invept_smpfunc(struct invept_bundle *bundle)
328328
{
329329
struct per_cpu_data *cpu_data;
330330

331-
smp_mb();
331+
hax_smp_mb();
332332
cpu_data = current_cpu_data();
333333
cpu_data->invept_res = VMX_SUCCEED;
334334

@@ -373,7 +373,7 @@ void invept(hax_vm_t *hax_vm, uint type)
373373

374374
bundle.type = type;
375375
bundle.desc = &desc;
376-
smp_call_function(&cpu_online_map, (void (*)(void *))invept_smpfunc,
376+
hax_smp_call_function(&cpu_online_map, (void (*)(void *))invept_smpfunc,
377377
&bundle);
378378

379379
/*

core/hax.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ struct hax_t *hax;
6161
extern hax_atomic_t vmx_cpu_num, vmx_enabled_num;
6262
static void hax_enable_vmx(void)
6363
{
64-
smp_call_function(&cpu_online_map, cpu_init_vmx, NULL);
64+
hax_smp_call_function(&cpu_online_map, cpu_init_vmx, NULL);
6565
}
6666

6767
static void hax_disable_vmx(void)
6868
{
69-
smp_call_function(&cpu_online_map, cpu_exit_vmx, NULL);
69+
hax_smp_call_function(&cpu_online_map, cpu_exit_vmx, NULL);
7070
}
7171

7272
static void free_cpu_vmxon_region(void)
@@ -410,7 +410,7 @@ static void hax_pmu_init(void)
410410
int ref_cpu_id = -1;
411411

412412
// Execute cpu_pmu_init() on each logical processor of the host CPU
413-
smp_call_function(&cpu_online_map, cpu_pmu_init, NULL);
413+
hax_smp_call_function(&cpu_online_map, cpu_pmu_init, NULL);
414414

415415
// Find the common APM version supported by all host logical processors
416416
// TODO: Theoretically we should do the same for other APM parameters

core/ia32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void ia32_wrmsr(uint32_t reg, uint64_t val)
7070
#endif
7171
}
7272

73-
uint64_t rdtsc(void)
73+
uint64_t ia32_rdtsc(void)
7474
{
7575
#ifdef HAX_ARCH_X86_32
7676
struct qword_val val = { 0 };

core/ia32_ops.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function __nmi, 0
161161
int 2h
162162
ret
163163

164-
function __fls, 1
164+
function asm_fls, 1
165165
xor reg_ret_32, reg_ret_32
166166
bsr reg_ret_32, reg_arg1_32
167167
ret

core/include/cpu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ struct per_cpu_data {
108108

109109
/*
110110
* These fields are used to record the result of certain VMX instructions
111-
* when they are used in a function wrapped by smp_call_function(). This is
111+
* when they are used in a function wrapped by hax_smp_call_function(). This is
112112
* because it is not safe to call hax_error(), etc. (whose underlying
113113
* implementation may use a lock) from the wrapped function to log a
114114
* failure; doing so may cause a deadlock and thus a host reboot, especially
115115
* on macOS, where mp_rendezvous_no_intrs() (the legacy Darwin API used by
116-
* HAXM to implement smp_call_function()) is known to be prone to deadlocks:
116+
* HAXM to implement hax_smp_call_function()) is known to be prone to deadlocks:
117117
* https://lists.apple.com/archives/darwin-kernel/2006/Dec/msg00006.html
118118
*/
119119
vmx_result_t vmxon_res;

core/include/emulate_ops.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
(0 * FASTOP_ALIGN))
4040

4141
/* Instruction handlers */
42-
typedef void(__cdecl em_handler_t)(void);
42+
typedef void(ASMCALL em_handler_t)(void);
4343
em_handler_t em_not;
4444
em_handler_t em_neg;
4545
em_handler_t em_inc;
@@ -72,7 +72,7 @@ em_handler_t em_bextr;
7272
em_handler_t em_andn;
7373

7474
/* Dispatch handlers */
75-
void __cdecl fastop_dispatch(void *handler, uint64_t *dst,
75+
void ASMCALL fastop_dispatch(void *handler, uint64_t *dst,
7676
uint64_t *src1, uint64_t *src2, uint64_t *flags);
7777

7878
#endif /* HAX_CORE_EMULATE_OPS_H_ */

0 commit comments

Comments
 (0)