diff mbox series

[kvm-unit-tests,v2,01/16] x86/apic: Use common library outb() implementation

Message ID 20240718124932.114121-2-papaluri@amd.com (mailing list archive)
State New, archived
Headers show
Series Introduce SEV-SNP support | expand

Commit Message

Paluri, PavanKumar July 18, 2024, 12:49 p.m. UTC
Remove the redundant local outb() implementation in favour of using the
common outb() implementation defined in lib/x86/asm/io.h, and convert
set_irq_line() to not open-code the out instruction.

Verfied no changes in assembly output for all three callsites, tested,
no functional changes were observed.

The rationale behind this change is that, support for SNP tests that are
introduced later will need apic sources to include common library io
code and if we don't remove apic's local outb() implementation, then we
get the following compilation conflicts:

In file included from lib/x86/apic.c:7:
lib/x86/asm/io.h:30:14: error: conflicting types for ‘outb’; have ‘void(unsigned char,  short unsigned int)’
   30 | #define outb outb
      |              ^~~~

Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com>
---
 lib/x86/apic.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/lib/x86/apic.c b/lib/x86/apic.c
index 0d15147677dd..bbc2d8ae85b1 100644
--- a/lib/x86/apic.c
+++ b/lib/x86/apic.c
@@ -4,6 +4,7 @@ 
 #include "processor.h"
 #include "smp.h"
 #include "asm/barrier.h"
+#include "asm/io.h"
 
 /* xAPIC and I/O APIC are identify mapped, and never relocated. */
 static void *g_apic = (void *)APIC_DEFAULT_PHYS_BASE;
@@ -23,11 +24,6 @@  static struct apic_ops *get_apic_ops(void)
 	return this_cpu_read_apic_ops();
 }
 
-static void outb(unsigned char data, unsigned short port)
-{
-	asm volatile ("out %0, %1" : : "a"(data), "d"(port));
-}
-
 void eoi(void)
 {
 	apic_write(APIC_EOI, 0);
@@ -232,7 +228,7 @@  void set_mask(unsigned line, int mask)
 
 void set_irq_line(unsigned line, int val)
 {
-	asm volatile("out %0, %1" : : "a"((u8)val), "d"((u16)(0x2000 + line)));
+	outb((u8)val, (u16)(0x2000 + line));
 }
 
 void enable_apic(void)