From 24289e4e69899b5f00ed2b3740eca3f5d5e22e50 Mon Sep 17 00:00:00 2001 From: fwsGonzo Date: Fri, 31 Mar 2017 12:31:45 +0200 Subject: [PATCH 1/2] virtionet: Add back legacy IRQ support --- src/drivers/virtionet.cpp | 9 ++++++++- src/drivers/virtionet.hpp | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/drivers/virtionet.cpp b/src/drivers/virtionet.cpp index 3bb5ae5f7c..f570697858 100644 --- a/src/drivers/virtionet.cpp +++ b/src/drivers/virtionet.cpp @@ -156,7 +156,8 @@ VirtioNet::VirtioNet(hw::PCI_Device& d) } else { - assert(0 && "Legacy IRQs not supported"); + auto irq = Virtio::get_legacy_irq(); + IRQ_manager::get().subscribe(irq, {this, &VirtioNet::legacy_handler}); } #ifndef NO_DEFERRED_KICK @@ -243,6 +244,12 @@ void VirtioNet::msix_xmit_handler() } } +void VirtioNet::legacy_handler() +{ + msix_recv_handler(); + msix_xmit_handler(); +} + void VirtioNet::add_receive_buffer(uint8_t* pkt) { // offset pointer to virtionet header diff --git a/src/drivers/virtionet.hpp b/src/drivers/virtionet.hpp index c7ddbafe97..e8b8e7c32a 100644 --- a/src/drivers/virtionet.hpp +++ b/src/drivers/virtionet.hpp @@ -220,6 +220,8 @@ class VirtioNet : Virtio, public net::Link_layer { void msix_xmit_handler(); void msix_conf_handler(); + void legacy_handler(); + /** Allocate and queue buffer from bufstore_ in RX queue. */ void add_receive_buffer(uint8_t*); From 130eb1ad4215a1bd6278c3a820f8cbc6e1085912 Mon Sep 17 00:00:00 2001 From: fwsGonzo Date: Fri, 31 Mar 2017 13:18:11 +0200 Subject: [PATCH 2/2] x86: Detect and enable XSAVE and AVX properly and separately --- src/arch/x86/start.asm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/arch/x86/start.asm b/src/arch/x86/start.asm index ce0615fe96..f7fa89d290 100644 --- a/src/arch/x86/start.asm +++ b/src/arch/x86/start.asm @@ -20,6 +20,7 @@ extern kernel_start global _start global __xsave_enabled global __avx_enabled +global __ecx_was %define MB_MAGIC 0x1BADB002 %define MB_FLAGS 0x3 ;; ALIGN + MEMINFO @@ -77,8 +78,10 @@ rock_bottom: ;; enable SSE before we enter C/C++ land call enable_sse + ;; try to enable XSAVE before checking AVX + call enable_xsave ;; enable AVX if xsave and avx supported on CPU - ;call enable_avx + call enable_avx ;; Place multiboot parameters on stack push ebx @@ -99,11 +102,24 @@ enable_sse: ret enable_xsave: + push eax + push ebx + ; check for XSAVE support + mov eax, 1 + xor ecx, ecx + cpuid + ; bit 26 ecx + and ecx, 0x04000000 + cmp ecx, 0x04000000 + jne xsave_not_supported ; enable XSAVE mov eax, cr4 or eax, 0x40000 mov cr4, eax mov WORD [__xsave_enabled], 0x1 +xsave_not_supported: + pop ebx + pop eax ret enable_avx: @@ -117,8 +133,6 @@ enable_avx: and ecx, 0x18000000 cmp ecx, 0x18000000 jne avx_not_supported - ;; enable XSAVE - call enable_xsave ;; enable AVX support xor ecx, ecx xgetbv