1 // Copyright 2022 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Copyright 2022 The ChromiumOS Authors
6 // Use of this source code is governed by a BSD-style license that can be
7 // found in the LICENSE file.
8 use hypervisor::kvm::*;
9 use hypervisor::*;
10 use vm_memory::GuestAddress;
11 use vm_memory::GuestMemory;
12
13 #[test]
set_gsi_routing()14 fn set_gsi_routing() {
15 let kvm = Kvm::new().unwrap();
16 let gm = GuestMemory::new(&[(GuestAddress(0), 0x10000)]).unwrap();
17 let vm = KvmVm::new(&kvm, gm, Default::default()).unwrap();
18 vm.create_irq_chip().unwrap();
19 vm.set_gsi_routing(&[]).unwrap();
20 vm.set_gsi_routing(&[IrqRoute {
21 gsi: 1,
22 source: IrqSource::Irqchip {
23 chip: IrqSourceChip::Gic,
24 pin: 3,
25 },
26 }])
27 .unwrap();
28 vm.set_gsi_routing(&[IrqRoute {
29 gsi: 1,
30 source: IrqSource::Msi {
31 address: 0xf000000,
32 data: 0xa0,
33 },
34 }])
35 .unwrap();
36 vm.set_gsi_routing(&[
37 IrqRoute {
38 gsi: 1,
39 source: IrqSource::Irqchip {
40 chip: IrqSourceChip::Gic,
41 pin: 3,
42 },
43 },
44 IrqRoute {
45 gsi: 2,
46 source: IrqSource::Msi {
47 address: 0xf000000,
48 data: 0xa0,
49 },
50 },
51 ])
52 .unwrap();
53 }
54