Skip to content

Commit 3b87e7c

Browse files
donshenglijinxia
authored andcommitted
HV: Add vuart port base address/IRQ Kconfig options
Adding Kconfig option to define the vuart port base address/IRQ. By default, use 0x3F8/IRQ4. For MRB, use 0x3E8/IRQ6. We are experiencing problems on NUC after changing from 0x3F8/IRQ4 to 0x3E8/IRQ6. Tracked-On: #1817 Change-Id: Ie407e51a7bc25ac0bb4c61453c969f1466fa33ca Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
1 parent b32e689 commit 3b87e7c

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

hypervisor/arch/x86/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,20 @@ config SERIAL_PIO_BASE
165165
The base address of the UART ports. This is logically 16-bit but used
166166
as a 64-bit integer.
167167

168+
config COM_BASE
169+
hex "Base address of the vuart port"
170+
depends on !RELEASE
171+
default 0x3f8
172+
help
173+
Base address of the vuart port.
174+
175+
config COM_IRQ
176+
hex "IRQ of the vuart port"
177+
depends on !RELEASE
178+
default 4
179+
help
180+
IRQ of the vuart port.
181+
168182
config MALLOC_ALIGN
169183
int "Block size in the heap for malloc()"
170184
range 8 32

hypervisor/arch/x86/assign.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ is_entry_active(const struct ptdev_remapping_info *entry)
4343
return atomic_load32(&entry->active) == ACTIVE_FLAG;
4444
}
4545

46+
#ifdef HV_DEBUG
4647
static bool ptdev_hv_owned_intx(const struct acrn_vm *vm, const union source_id *virt_sid)
4748
{
4849
/* vm0 vuart pin is owned by hypervisor under debug version */
49-
if (is_vm0(vm) && (virt_sid->intx_id.pin == COM1_IRQ)) {
50+
if (is_vm0(vm) && (virt_sid->intx_id.pin == CONFIG_COM_IRQ)) {
5051
return true;
5152
} else {
5253
return false;
5354
}
5455
}
56+
#endif
5557

5658
static uint64_t calculate_logical_dest_mask(uint64_t pdmask)
5759
{
@@ -637,9 +639,11 @@ int ptdev_intx_pin_remap(struct acrn_vm *vm, uint8_t virt_pin,
637639
*/
638640

639641
/* no remap for hypervisor owned intx */
642+
#ifdef HV_DEBUG
640643
if (ptdev_hv_owned_intx(vm, &virt_sid)) {
641644
goto END;
642645
}
646+
#endif
643647

644648
/* query if we have virt to phys mapping */
645649
spinlock_obtain(&ptdev_lock);

hypervisor/debug/vuart.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
#include "uart16550.h"
3434

35-
#define COM1_BASE 0x3E8U
3635

3736
#ifndef CONFIG_PARTITION_MODE
3837
static char vuart_rx_buf[RX_BUF_SIZE];
@@ -132,10 +131,10 @@ static void vuart_toggle_intr(const struct acrn_vuart *vu)
132131
uint32_t operation;
133132

134133
intr_reason = vuart_intr_reason(vu);
135-
vioapic_get_rte(vu->vm, COM1_IRQ, &rte);
134+
vioapic_get_rte(vu->vm, CONFIG_COM_IRQ, &rte);
136135

137136
/* TODO:
138-
* Here should assert vuart irq according to COM1_IRQ polarity.
137+
* Here should assert vuart irq according to CONFIG_COM_IRQ polarity.
139138
* The best way is to get the polarity info from ACIP table.
140139
* Here we just get the info from vioapic configuration.
141140
* based on this, we can still have irq storm during guest
@@ -150,8 +149,8 @@ static void vuart_toggle_intr(const struct acrn_vuart *vu)
150149
GSI_SET_HIGH : GSI_SET_LOW;
151150
}
152151

153-
vpic_set_irq(vu->vm, COM1_IRQ, operation);
154-
vioapic_set_irq(vu->vm, COM1_IRQ, operation);
152+
vpic_set_irq(vu->vm, CONFIG_COM_IRQ, operation);
153+
vioapic_set_irq(vu->vm, CONFIG_COM_IRQ, operation);
155154
}
156155

157156
static void vuart_write(struct acrn_vm *vm, uint16_t offset_arg,
@@ -323,7 +322,7 @@ static void vuart_register_io_handler(struct acrn_vm *vm)
323322
{
324323
struct vm_io_range range = {
325324
.flags = IO_ATTR_RW,
326-
.base = COM1_BASE,
325+
.base = CONFIG_COM_BASE,
327326
.len = 8U
328327
};
329328

@@ -402,7 +401,7 @@ void vuart_init(struct acrn_vm *vm)
402401
vm->vuart.dlh = (uint8_t)(divisor >> 8U);
403402

404403
vm->vuart.active = false;
405-
vm->vuart.base = COM1_BASE;
404+
vm->vuart.base = CONFIG_COM_BASE;
406405
vm->vuart.vm = vm;
407406
vuart_fifo_init(vu);
408407
vuart_lock_init(vu);

hypervisor/include/debug/vuart.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,11 @@ struct acrn_vuart {
6969
extern int8_t vuart_vmid;
7070
#endif
7171
#ifdef HV_DEBUG
72-
#define COM1_IRQ 6U
7372
void vuart_init(struct acrn_vm *vm);
7473
struct acrn_vuart *vuart_console_active(void);
7574
void vuart_console_tx_chars(struct acrn_vuart *vu);
7675
void vuart_console_rx_chars(struct acrn_vuart *vu);
7776
#else
78-
#define COM1_IRQ 0xFFU
7977
static inline void vuart_init(__unused struct acrn_vm *vm)
8078
{
8179
}

0 commit comments

Comments
 (0)