Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp335357imm; Thu, 6 Sep 2018 03:17:45 -0700 (PDT) X-Received: by 2002:a62:50c3:: with SMTP id g64-v6mr2032748pfj.244.1536228825946; Thu, 06 Sep 2018 03:13:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYE69c4rtwex73PvM2ddfk8PrulFrJKjpknM1nXbb4DdLtZpXq7lVIcSNJnFxrF1DkLV/kD X-Received: by 2002:a62:50c3:: with SMTP id g64-v6mr2032688pfj.244.1536228825206; Thu, 06 Sep 2018 03:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536228825; cv=none; d=google.com; s=arc-20160816; b=rvRGetYmt4S6PGxVMx7C8OIzDalP9qrnVo/JLbsuH2m5jOG11J84VntULeftkqaEUW fgQuT3ORSoxyVFJIR2dwgTDEAlHAPjBire2j+rIG+747A9CwKy2NrIOos+YwntdjOxwE qbOLP6Dfiw3wfmvS70dkLuaJnp03i4BXiREeLJCeit1y+Wo4c7LzYN80aXD9l8rkYioR T6mM+YxUPjfJyyOFrQBf9PlIzS26yNFDmPF2w4gfPJVi2xJi4s5jKeM+C1xArFbonBdG Y9dvgHtrAwRQu1GY3FWti6/c7ZhNmgPQJt5b3I/CTnbX8ZBtJdNubR0y1ApCutM1AcAf 5M7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:cc:to :subject:autocrypt:openpgp:from; bh=vq2kWOIxZDYHhY7XUhGt+7NZOS/IqfanLy98iDgY/SA=; b=P6qTxpc8tYnmZO6DL85lCTe79akmKMba1COsvLDic4Ix19RmXYREmvin9v6OICazpf fKrn/wI/knRS05l/+Ff1RTCqP5trmNTXplXFi2Hcb0pxAAFtktIsC37zq3VtaTl7Iebp HpeiONwgLb9IkVMkK0bMlZgun5oxmjBr7DglsvVEaAg63/Wl2lBzDHlfAnxhIcxhXdgn 2iWpyDy0hI/dvdNa6ZFN633bstMYnhdOgny9uRWAlKjAQDPxZCNlZCdES2Rw5lwSZEq3 Ga20p6+7/Ar2pJf0yKyI3c9GqNmLUQhyXxSrLj0797FQxW2yHLsVJLVWz3NDvbWt0SRs n1vQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a65-v6si4465734pge.694.2018.09.06.03.13.06; Thu, 06 Sep 2018 03:13:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728335AbeIFO0H (ORCPT + 99 others); Thu, 6 Sep 2018 10:26:07 -0400 Received: from serv1.kernkonzept.com ([88.99.87.17]:47297 "EHLO mx.kernkonzept.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728001AbeIFO0H (ORCPT ); Thu, 6 Sep 2018 10:26:07 -0400 X-Greylist: delayed 1768 seconds by postgrey-1.27 at vger.kernel.org; Thu, 06 Sep 2018 10:26:05 EDT Received: from ip5f5b9406.dynamic.kabel-deutschland.de ([95.91.148.6] helo=localhost.localdomain) by mx.kernkonzept.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) id 1fxqUG-0000xv-Ot; Thu, 06 Sep 2018 11:22:04 +0200 From: Philipp Eppelt Openpgp: preference=signencrypt Autocrypt: addr=philipp.eppelt@kernkonzept.com; prefer-encrypt=mutual; keydata= xsFN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p0qL bvLTDigaTS2LxxfW5GdoFQerzFGr6TX7BuHHm9RIsrzMs/IhEKZVI2aoWlrmF9tj3U9meqsB dCUAEQEAAcLBZQQYAQgADwUCV35OfwIbDAUJB4TOAAAKCRCDy52RMrDsISbbEACM8a6Q4sVC cW2OGeIuEwedWK76kcwM0PZNGHyPon0R1S5SklkDz4Itt6vnOk2feeu8MErSUuSBKAGgrjNx PPYZGq9HZ4HUoVwHPwHKzr7wnFvfIIKXHRs+N0tFm9mWXfFturvuhNXTtUQDM44FEnachu8s hx0D+k1Wv9NIE1QAQE0w5scXy2RMq2Cdp4FaQzkp7mcF/Fwlt6LNqhAly4zrYby6Z3eY/gBG Lsmvvj7fVxhsKIJEvROfHEUYyQJ7WZ1c5SpGWMWvjOwzWh4YH21FkcEpDur35V649amOcfVF 3c+A5E31sSnVOGb393NxGN9bWPaVhAp7C7l22P6M0q4bCY6IEjEULR9xFNT/P7+UturI7qag UgjAhoQ2Z101DDZpy/829x9swByk3VaViBrRICnNVUHSp0Vxroxg01aaW+Q4vqqbTuyWClXd rXwuP2mZdtR4/uUSTGxVyte7As7hDBEFir7louqGvh4yMzmXcVZ4NPWVnPHMMRe7J+eqjPQN xLFwzryjJIBhjqfgxE3xWqky9MxDRh4T5zAe49DIAQpqyWW9i4Nu369DX2V5IrLC++Lfkawk ArmL3zoHgJqo7M3l2Y69wIV/Jz2f0s/WO6EDU226VIvflkAmAPxy5aEmjKSyoMNf4+bmOlXs khuLCBwcsLPhxbjZ6s1AXffYGA== Subject: x86/apic: MSI address malformed for "flat" driver To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner Message-ID: Date: Thu, 6 Sep 2018 11:22:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I believe the x86/APIC implementation does not behave according to the Intel SDM specification, when it comes to composing MSI messages for the "flat" APIC driver as of a31e58e129f73ab5b04016330b13ed51fde7a961 . APIC "flat" driver and MSI address composing from the current master (2018-09-02, 60c1f89241d49bacf71035470684a8d7b4bb46ea): static struct apic apic_flat __ro_after_init = { ... .irq_delivery_mode = dest_Fixed, .irq_dest_mode = 1, /* logical */ ... .calc_dest_apicid = apic_flat_calc_apicid, }; static void irq_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) { ... msg->address_lo = MSI_ADDR_BASE_LO | ((apic->irq_dest_mode == 0) ? MSI_ADDR_DEST_MODE_PHYSICAL : MSI_ADDR_DEST_MODE_LOGICAL) | MSI_ADDR_REDIRECTION_CPU | MSI_ADDR_DEST_ID(cfg->dest_apicid); ... } The "flat" driver defines the MSI addressing scheme to be used as logical addressing in flat mode. The MSI msg address is composed accordingly, but sets MSI_ADDR_REDIRECTION_CPU which is a zero at bit[3]. The intel SDM states for the MSI address format (SDM vol.3 10.11): 31-20 0xfee 19-12 Destination ID (DID) 11-4 Reserved 3 Redirection Hint (RH) 2 Destination Mode (DM) 1-0 XX The relation of RH and DM is, if RH is 0, DM is ignored and the DID field is interpreted the same as are bits [63:56] in the IO-APIC, meaning as local APIC ID. If RH is 1 and DM is 0, physical addressing is used (see the apic_physflat driver). If RH is 1 and DM is 1, logical addressing is used which splits up into flat and cluster mode determined by the APICs DFR and LDR using the logical APIC address. Currently, irq_msi_compose_msg composes for the "flat" driver an address like 0xfee0'1004 for a 64-bit single-core system without IO-APIC and MSI remapping and no ACPI (a virtual system). That's incorrect because RH == 0 means the DID should show a local APIC ID, but it shows a logical APIC ID for logical flat addressing (DM == 1, DFR[31:28] == 0). The LDR register is correctly set up as well, so the behavior is consistent, but completely ignores the RH value. The DID calculation producing the local APIC ID should be done by "apic_default_calc_apicid", when the RH bit is not set. That's my analysis I want to put up for discussion. I hope to have included all necessary information on my setup, please let me know if I missed something. I don't have an overview over all affected parts in and around the APIC, so I am currently not able to produce a patch (besides just changing .calc_dest_apicid which makes the "flat" driver inconsistent). Cheers, Philipp p.s. I am on vacation the next three weeks starting Saturday, so forgive me for not answering in the meantime. Kernel config: x86_64_defconfig + CONFIG_KERNEL_XZ=y CONFIG_BLK_DEV_INITRD=y CONFIG_CC_STACKPROTECTOR_REGULAR=y CONFIG_PCI_MSI=y CONFIG_OF=y CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_SIZE=16384 CONFIG_VIRTIO_BLK=y CONFIG_SERIO_RAW=y CONFIG_VT_HW_CONSOLE_BINDING=y CONFIG_VIRTIO_CONSOLE=y CONFIG_HW_RANDOM_VIRTIO=y CONFIG_VIRTIO_PCI=y # CONFIG_VIRTIO_PCI_LEGACY is not set CONFIG_VIRTIO_INPUT=y CONFIG_EXT3_FS=y CONFIG_TMPFS=y CONFIG_MESSAGE_LOGLEVEL_DEFAULT=7 CONFIG_DEBUG_FS=y CONFIG_STACKTRACE=y CONFIG_MEMTEST=y virtual System: x86-64 64-bit UP, 128MB RAM, no ACPI, no MSI remapping, no IO-APIC -- philipp.eppelt@kernkonzept.com - Tel. 0351-41 883 221 http://www.kernkonzept.com