Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2417569ybf; Mon, 2 Mar 2020 08:13:24 -0800 (PST) X-Google-Smtp-Source: ADFU+vt75miBiV5en5FqDqacYnUJfiU1roAZJ7aBU7K5flI9phYZ6RKZcnxUI/wdAN4phu1S8mAH X-Received: by 2002:aca:5c46:: with SMTP id q67mr155822oib.75.1583165604763; Mon, 02 Mar 2020 08:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583165604; cv=none; d=google.com; s=arc-20160816; b=D0FYKZs+Y9IQTnhuXV3cSXXftZTKrZ8PJkRPqZNeRkeBLoOeuzcYtqz/E+92G5pDzf uLtk+qYN8XL44FvweQF9e2NAyo1z+yOyY8FTHCO1e62tPTma11/q75py7p96xzn0CwYr AV2R+rK94Om35VTdlzOP+xcGi/7GfdP7Qwq4WojIXvLTHKn3w9ftEaBQCzs3bNfP9aqo onAXE5E4dhQDnmNkbWjpv0cuvrqHrTV/BIvWsMfeTquhG28R0IwddlFwZ2hP7dUTZ0PG 1o+ALPJGf4jrsDbaKLO99E6XFY8dLE9U2evT9iOMBJyAdRQDFdB/if4T9HN6BQEL0NMi Nt8g== 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:subject :from:cc:to; bh=IwbFxtn2XCQJJUGQK5EcKp0cJzUbepTy+H6EcK+EXIk=; b=TaGoy7xieW9U2FxJEapz4xK7JOsRjk9QaEwg1tzVUA5kz690yzogZBD57sn217DK/X fQyyglSUorFuYh1MJrmtYQvktoUijUWalJ2N0Id6r8fVrFkzfDXmvOu+i2LjmWYXMd0q i4HBUNGAP4WyibkI5ilHNY7CqIkCYWB8LgeYQn/5wLAmV/xWESYPuQ+0/E3RHGz2oxco 1/JKGuLUsjx6UR7fVTH1SgAQ5Rql+P0NU+D6lAn698r3tGoCxL0Eel8GY31M1JSoHuFw p51YNErxrw4p3k3JnwhxaFsGMXYNrikk9el+YE2tSWbhNfzu4/ZYwWRT1TiqQrtQ0b+2 awNg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m9si6978731otq.304.2020.03.02.08.13.10; Mon, 02 Mar 2020 08:13:24 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbgCBQLa (ORCPT + 99 others); Mon, 2 Mar 2020 11:11:30 -0500 Received: from david.siemens.de ([192.35.17.14]:39428 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbgCBQLa (ORCPT ); Mon, 2 Mar 2020 11:11:30 -0500 Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id 022GBMiU029281 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Mar 2020 17:11:22 +0100 Received: from [139.25.68.37] ([139.25.68.37]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id 022GBM7R009884; Mon, 2 Mar 2020 17:11:22 +0100 To: x86 Cc: Linux Kernel Mailing List From: Jan Kiszka Subject: x2apic_wrmsr_fence vs. Intel manual Message-ID: <783add60-f6c7-c8c6-b369-42e5ebfbf8c9@siemens.com> Date: Mon, 2 Mar 2020 17:11:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, as I generated a nice bug around fence vs. x2apic icr writes, I studied the kernel code and the Intel manual in this regard more closely. But there is a discrepancy: arch/x86/include/asm/apic.h: /* * Make previous memory operations globally visible before * sending the IPI through x2apic wrmsr. We need a serializing instruction or * mfence for this. */ static inline void x2apic_wrmsr_fence(void) { asm volatile("mfence" : : : "memory"); } Intel SDM, 10.12.3 MSR Access in x2APIC Mode: "A WRMSR to an APIC register may complete before all preceding stores are globally visible; software can prevent this by inserting a serializing instruction or the sequence MFENCE;LFENCE before the WRMSR." The former dates back to ce4e240c279a, but that commit does not mention why lfence is not needed. Did the manual read differently back then? Or why are we safe? To my reading of lfence, it also has a certain instruction serializing effect that mfence does not have. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux