Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 1 | Upstream-Status: Backport [4ccd5fe22feb95137d325f422016a6473541fe9f] |
| 2 | Signed-off-by: Ross Burton <ross.burton@arm.com> |
| 3 | |
| 4 | From ec2d4aa7ca28127faa7ccdbf89d2bf5a4984b62f Mon Sep 17 00:00:00 2001 |
| 5 | From: Joelle van Dyne <j@getutm.app> |
| 6 | Date: Sun, 27 Feb 2022 13:06:55 -0800 |
| 7 | Subject: [PATCH] pc: add option to disable PS/2 mouse/keyboard |
| 8 | |
| 9 | On some older software like Windows 7 installer, having both a PS/2 |
| 10 | mouse and USB mouse results in only one device working property (which |
| 11 | might be a different device each boot). While the workaround to not use |
| 12 | a USB mouse with such software is valid, it creates an inconsistent |
| 13 | experience if the user wishes to always use a USB mouse. |
| 14 | |
| 15 | This introduces a new machine property to inhibit the creation of the |
| 16 | i8042 PS/2 controller. |
| 17 | |
| 18 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
| 19 | Message-Id: <20220227210655.45592-1-j@getutm.app> |
| 20 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> |
| 21 | Signed-off-by: Michael S. Tsirkin <mst@redhat.com> |
| 22 | --- |
| 23 | hw/i386/pc.c | 28 ++++++++++++++++++++++++++-- |
| 24 | include/hw/i386/pc.h | 2 ++ |
| 25 | 2 files changed, 28 insertions(+), 2 deletions(-) |
| 26 | |
| 27 | diff --git a/hw/i386/pc.c b/hw/i386/pc.c |
| 28 | index a2ef40ecbc..8a6a089ee2 100644 |
| 29 | --- a/hw/i386/pc.c |
| 30 | +++ b/hw/i386/pc.c |
| 31 | @@ -1008,7 +1008,8 @@ static const MemoryRegionOps ioportF0_io_ops = { |
| 32 | }, |
| 33 | }; |
| 34 | |
| 35 | -static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport) |
| 36 | +static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, |
| 37 | + bool create_i8042, bool no_vmport) |
| 38 | { |
| 39 | int i; |
| 40 | DriveInfo *fd[MAX_FD]; |
| 41 | @@ -1030,6 +1031,10 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | + if (!create_i8042) { |
| 46 | + return; |
| 47 | + } |
| 48 | + |
| 49 | i8042 = isa_create_simple(isa_bus, "i8042"); |
| 50 | if (!no_vmport) { |
| 51 | isa_create_simple(isa_bus, TYPE_VMPORT); |
| 52 | @@ -1125,7 +1130,8 @@ void pc_basic_device_init(struct PCMachineState *pcms, |
| 53 | i8257_dma_init(isa_bus, 0); |
| 54 | |
| 55 | /* Super I/O */ |
| 56 | - pc_superio_init(isa_bus, create_fdctrl, pcms->vmport != ON_OFF_AUTO_ON); |
| 57 | + pc_superio_init(isa_bus, create_fdctrl, pcms->i8042_enabled, |
| 58 | + pcms->vmport != ON_OFF_AUTO_ON); |
| 59 | } |
| 60 | |
| 61 | void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus) |
| 62 | @@ -1506,6 +1512,20 @@ static void pc_machine_set_hpet(Object *obj, bool value, Error **errp) |
| 63 | pcms->hpet_enabled = value; |
| 64 | } |
| 65 | |
| 66 | +static bool pc_machine_get_i8042(Object *obj, Error **errp) |
| 67 | +{ |
| 68 | + PCMachineState *pcms = PC_MACHINE(obj); |
| 69 | + |
| 70 | + return pcms->i8042_enabled; |
| 71 | +} |
| 72 | + |
| 73 | +static void pc_machine_set_i8042(Object *obj, bool value, Error **errp) |
| 74 | +{ |
| 75 | + PCMachineState *pcms = PC_MACHINE(obj); |
| 76 | + |
| 77 | + pcms->i8042_enabled = value; |
| 78 | +} |
| 79 | + |
| 80 | static bool pc_machine_get_default_bus_bypass_iommu(Object *obj, Error **errp) |
| 81 | { |
| 82 | PCMachineState *pcms = PC_MACHINE(obj); |
| 83 | @@ -1616,6 +1636,7 @@ static void pc_machine_initfn(Object *obj) |
| 84 | pcms->smbus_enabled = true; |
| 85 | pcms->sata_enabled = true; |
| 86 | pcms->pit_enabled = true; |
| 87 | + pcms->i8042_enabled = true; |
| 88 | pcms->max_fw_size = 8 * MiB; |
| 89 | #ifdef CONFIG_HPET |
| 90 | pcms->hpet_enabled = true; |
| 91 | @@ -1744,6 +1765,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) |
| 92 | object_class_property_add_bool(oc, "hpet", |
| 93 | pc_machine_get_hpet, pc_machine_set_hpet); |
| 94 | |
| 95 | + object_class_property_add_bool(oc, PC_MACHINE_I8042, |
| 96 | + pc_machine_get_i8042, pc_machine_set_i8042); |
| 97 | + |
| 98 | object_class_property_add_bool(oc, "default-bus-bypass-iommu", |
| 99 | pc_machine_get_default_bus_bypass_iommu, |
| 100 | pc_machine_set_default_bus_bypass_iommu); |
| 101 | diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h |
| 102 | index 9ab39e428f..642c915aa3 100644 |
| 103 | --- a/include/hw/i386/pc.h |
| 104 | +++ b/include/hw/i386/pc.h |
| 105 | @@ -46,6 +46,7 @@ typedef struct PCMachineState { |
| 106 | bool sata_enabled; |
| 107 | bool pit_enabled; |
| 108 | bool hpet_enabled; |
| 109 | + bool i8042_enabled; |
| 110 | bool default_bus_bypass_iommu; |
| 111 | uint64_t max_fw_size; |
| 112 | |
| 113 | @@ -62,6 +63,7 @@ typedef struct PCMachineState { |
| 114 | #define PC_MACHINE_SMBUS "smbus" |
| 115 | #define PC_MACHINE_SATA "sata" |
| 116 | #define PC_MACHINE_PIT "pit" |
| 117 | +#define PC_MACHINE_I8042 "i8042" |
| 118 | #define PC_MACHINE_MAX_FW_SIZE "max-fw-size" |
| 119 | /** |
| 120 | * PCMachineClass: |
| 121 | -- |
| 122 | 2.25.1 |
| 123 | |