Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp824444rwb; Thu, 12 Jan 2023 12:52:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBLJFaYwRdcTdE4x3w4XHWP4st6uj4xGeBfoAuDSTYykYTcYO4nRAcL8R7p7g5cJDLGYpS X-Received: by 2002:a17:907:6f17:b0:7c1:5019:50c6 with SMTP id sy23-20020a1709076f1700b007c1501950c6mr3181494ejc.72.1673556763909; Thu, 12 Jan 2023 12:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673556763; cv=none; d=google.com; s=arc-20160816; b=md90N5A0zt9YkwTEqJallVOozcZEA8PTe6ncnz+k0A4M0sajLyoLppF7JFO6mkSO8B bF6Wuwwfcc5gGTwJZRf7n5CT7NPOldcSvIBaOy2LtSG5OyXXUqWuN1Utq4ljvBuYWamI Zh3hG3zEBHkz/1CtwyS32ICD4R/V2AUw8Q8B85LyGmk3/xQg4RabykDrafkW9D+XIK/s zF6OvaUn3xR0dou6HRLMqbLhZK22EthQ+e2nbYG8Yn28EpVfq8Vl6PjoVuIgYos2Yttr G489SLEGktGTKMJPdZYep6StJFzuLVpN0c9lIirP49P0eR9n8ZzZyCymFXDUgl7quMaz CXxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=bSFMK1rIzGzwTL932jNXF415JVKVles1xNGjys4yKU0=; b=jCFkqqJB1mD/s/H85NeQeKroU5+loPJBbxdki8jogLLQYykNqlNOlCTRNkkhq4Shvw v+zBjy0Jpofsp2nnMbDkPqQ56d4K6nXRB3WN2vFQsgcZf8r9SfpFoj4qtIMe7KDrY9e6 o8p1fTgwdGcobsBjTa9guxNRzl0buJ89Hg9UGjJQItkJEsdpFFMTiUSGjqyvX01pHv3A g4e4SjFNuu8/nKe7f/WEnSIcyw3uheDKHX/Z9JqtudoigXCAyTtgg5qmlhx7acieKj9K e0IS8/5XlgOuvHI3qQNGzC1M7bftMVDPgSTfiof9muVRofBZ5/uHwcI/Cm+tQN7yzrCK eIug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jTjUbgU6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn11-20020a1709070d0b00b007c13387a548si20854451ejc.26.2023.01.12.12.52.31; Thu, 12 Jan 2023 12:52:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jTjUbgU6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240662AbjALUMM (ORCPT + 52 others); Thu, 12 Jan 2023 15:12:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240882AbjALUBZ (ORCPT ); Thu, 12 Jan 2023 15:01:25 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0827E28D; Thu, 12 Jan 2023 12:00:35 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673553633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bSFMK1rIzGzwTL932jNXF415JVKVles1xNGjys4yKU0=; b=jTjUbgU6p2aPf5TA4DXQik+3vZFGH7cZAVb6GOcwrK6WQ1JBxW2/6C2oloFxXdREJDDPCL kkQwQZC2ULLNvxT2ulvf6mx9n97xHK+qQpHP3Km1FKLK82mGmaexaLQvXzcLorARASLgpb hc/zeaHlwCNbjlsBnWqk+xz1Qe/hV7BBLA3XBCFOnU8UXscb+8yaVMc9KhtO7BDT4WdFWj LlfJZObawvKqhOdXtgP9oq2xowAHdmVw25GgwzmAqde3rleDeZ8YIDUMu1UfItBzoBg+nS EJGurVRSxgq9FnUt0OSr+JlcELbRv61SakfsjUuRl8Tpk+xRhkyzlbe4mkkWeA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673553633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bSFMK1rIzGzwTL932jNXF415JVKVles1xNGjys4yKU0=; b=0B1pSFMu/wK0JVav1pjVqrqkngsDSE55g43YcIhaMQfO0NU7pyA/9XMv2C3bvE9TGrGQs2 BrowKCLmPgMB8VCw== To: Jinank Jain Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, arnd@arndb.de, peterz@infradead.org, jpoimboe@kernel.org, jinankjain@linux.microsoft.com, seanjc@google.com, kirill.shutemov@linux.intel.com, ak@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, anrayabh@linux.microsoft.com, mikelley@microsoft.com Subject: Re: [PATCH v10 5/5] x86/hyperv: Change interrupt vector for nested root partition In-Reply-To: <021f748f15870f3e41f417511aa88607627ec327.1672639707.git.jinankjain@linux.microsoft.com> References: <021f748f15870f3e41f417511aa88607627ec327.1672639707.git.jinankjain@linux.microsoft.com> Date: Thu, 12 Jan 2023 21:00:32 +0100 Message-ID: <87o7r3ed5r.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jinank! On Mon, Jan 02 2023 at 07:12, Jinank Jain wrote: > --- a/arch/x86/include/asm/irq_vectors.h > +++ b/arch/x86/include/asm/irq_vectors.h > +/* > + * FIXME: Change this, once Microsoft Hypervisor changes its assumption > + * around VMBus interrupt vector allocation for nested root partition. > + * Or provides a better interface to detect this instead of hardcoding. > + */ > +#define HYPERV_INTR_NESTED_VMBUS_VECTOR 0x31 arch/x86/include/asm/irq_vectors.h line 47: /* * Vectors 0x30-0x3f are used for ISA interrupts. * round up to the next 16-vector boundary */ #define ISA_IRQ_VECTOR(irq) (((FIRST_EXTERNAL_VECTOR + 16) & ~15) + irq) So this overlaps with the legacy interrupt vector space. > +#ifdef CONFIG_HYPERV > + /* > + * This is a hack because we cannot install this interrupt handler > + * via alloc_intr_gate as it does not allow interrupt vector less > + * than FIRST_SYSTEM_VECTORS. And hyperv does not want anything other > + * than 0x31-0x34 as the interrupt vector for vmbus interrupt in case > + * of nested setup. > + */ > + INTG(HYPERV_INTR_NESTED_VMBUS_VECTOR, asm_sysvec_hyperv_nested_vmbus_intr), > +#endif I agree, that this is a hack, but that puts it mildly: It's a completely broken hack. > +DECLARE_IDTENTRY_SYSVEC(HYPERV_INTR_NESTED_VMBUS_VECTOR, sysvec_hyperv_nested_vmbus_intr); This generates the low level entry stub for vector 0x31 at compile time, which competes with the interrupt stub for external interrupts generated by: SYM_CODE_START(irq_entries_start) Now the above INTG() hard-codes the IDT entry for vector 0x31 into the apic_idts table. That marks it as system vector which in turn prevents idt_setup_apic_and_irq_gates() to install the IDT entry for the external vector on _ALL_ systems unconditionally. IOW, you broke world except for systems which do not use the legacy interrupt space. Congrats! That legacy space is hardcoded and that's clearly documented so. 0x31 becomes IRQ1 - usually the i8042 - which makes it pretty much guaranteed that this collides and fails. The worst case consequence is a fully uncontrolled interrupt storm which is not even detectable. So this patch is /dev/null material and either the hypervisor side makes it possible to use a different vector space or this needs some very careful modifications to the legacy ISA vector assignment. Thanks, tglx