forked from google/syzkaller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executor/common_kvm_ppc64: fix KVM support
Turns out the ifuzz on powerpc did not ever properly work. This fixes syz_kvm_setup_cpu$ppc64: Enable the PAPR KVM capability (otherwise KVM_RUN fails right away). Finish generated sequences with the software debug breakpoint as there is no x86's "hlt" variant on POWER and otherwise KVM won't exit. Add exception handlers, use the software debug breakpoint instruction to trigger immediate exit from KVM with the only exception of the decrementer interrupt handler (timer) to recharge the timer and continue. Define and use endianness selection flag (Big vs. Little endian). Define the code generator similar to kvm_gen.cc which for now contains 2 simple tests and the decrementer interrupt handler code. Add test cases to the executor so "bin/linux_ppc64le/syz-executor test" can run some sensible tests. The tests copy 0xbadc0de around similar to x86 and uses gpr[3] is a return value register (similar to EAX). Signed-off-by: Alexey Kardashevskiy <[email protected]>
- Loading branch information
Showing
10 changed files
with
437 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
executor/kvm_amd64.S.h linguist-generated | ||
executor/kvm_ppc64le.S.h linguist-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright 2021 syzkaller project authors. All rights reserved. | ||
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. | ||
|
||
// nolint: lll | ||
//go:generate bash -c "gcc -DGOARCH_$GOARCH=1 kvm_gen.cc kvm_ppc64le.S -o kvm_gen && ./kvm_gen > kvm_ppc64le.S.h && rm ./kvm_gen" | ||
|
||
package executor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2021 syzkaller project authors. All rights reserved. | ||
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. | ||
|
||
// kvm_gen.cc generates machine code from this file and saves it into kvm_ppc64le.S.h. | ||
|
||
// +build | ||
|
||
#include "kvm.h" | ||
|
||
#define LOAD64(rn,name) \ | ||
lis rn,name##@highest; \ | ||
ori rn,rn,name##@higher; \ | ||
rldicr rn,rn,32,31; \ | ||
oris rn,rn,name##@h; \ | ||
ori rn,rn,name##@l | ||
|
||
.global kvm_ppc64_mr, kvm_ppc64_mr_end | ||
kvm_ppc64_mr: | ||
LOAD64(5, 0xbadc0de) | ||
mr 4,5 | ||
mr 3,4 | ||
kvm_ppc64_mr_end: | ||
|
||
.global kvm_ppc64_ld, kvm_ppc64_ld_end | ||
kvm_ppc64_ld: | ||
LOAD64(15, 0xbadc0de) | ||
// Last double word of vma[24] | ||
LOAD64(25, 24 * 0x10000 - 8) | ||
std 15, 0(25) | ||
ld 3, 0(25) | ||
kvm_ppc64_ld_end: | ||
|
||
.global kvm_ppc64_recharge_dec, kvm_ppc64_recharge_dec_end | ||
kvm_ppc64_recharge_dec: | ||
LOAD64(20,0x7ffffff) | ||
#define SPRN_DEC 0x016 /* Decrement Register */ | ||
mtspr SPRN_DEC,20 | ||
rfid | ||
kvm_ppc64_recharge_dec_end: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.