From patchwork Tue Dec 19 15:12:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vegard Nossum X-Patchwork-Id: 181055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2011382dyi; Tue, 19 Dec 2023 07:19:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6Z/ZNJ1Rm54MkZleRe+hHu27JuiRQU/dhj/jqIowGGlre3C9FiTDc/p/XOwrIbjx4KLat X-Received: by 2002:a17:90a:4592:b0:286:a708:cd2c with SMTP id v18-20020a17090a459200b00286a708cd2cmr7845512pjg.9.1702999142186; Tue, 19 Dec 2023 07:19:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702999142; cv=none; d=google.com; s=arc-20160816; b=G/9U8f/YTYhnxuhO4jUQXqSh4KVjZuYTGVxvR9GgtNHj0yh0RvFxfroUfEZMgNTbZg qAicxRgKORc6i29sDhqKDvKZPRaKhMEq7OHNYlTw99iQRJBHTyD3ec4UinGlBEI4ZIeU SB01wnr86DpRvUaUiRaYUrEAu0O7JTT3dxs47zbEfv6OxmuYMmqEmOAfa5WLJe8vFBiW kfGi+ijc1cmtiJQc9/xrZ8AfSt+Oc02/wfqnfRKEZNCabolLvAG2gA5pi3I9omb5Qk60 NOZiaBBf8GSzn/IX2vnSK3V2L3CeZxgJ5Gedu+rcVWQmxF/NX7+CrxNoBmTQDQO+UGKf OHWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7NuuEtCagypjfe1xtc4mlaQysed4lhnQXPrzUeLCbiE=; fh=RhdOiDJkEaTzdEeQNntGp6ShHoLQM12s2l5qxiLPvAE=; b=rJXepT2NZirE3UhFZe0uzrndYnJolEo98kSyhVsSrhudMAKzZo1gE2fcAHjOIIrSSY obo0SUUF026UNSZWX17BttiARB/2xrdmKwXjJHx2Z4MJhJEbvE1DLyd8Zi+sw3EUIlrD fR0hXSY/qSOHbHYHlUP8Xxcm/D/USkqm0XgNs8g2gcz8VtnbJdN6MRTjoDy22WQtV32U wCQMRUS2vVpwatnlCm4CbVP1+51QnE75PT00svnUBJX2fMd+lo/D3Egc633WxceH/9XC NRfV28jwrMFlPu6OU+M6R3uB2gng5OrbVlxxgiR9KGHQ/apO8CyfryW+rIRCz8XWVWgw rsdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=OlczGLQw; spf=pass (google.com: domain of linux-kernel+bounces-5461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5461-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h20-20020a17090aa89400b0028bb648dfddsi1348544pjq.156.2023.12.19.07.19.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 07:19:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=OlczGLQw; spf=pass (google.com: domain of linux-kernel+bounces-5461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5461-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 72D27289014 for ; Tue, 19 Dec 2023 15:13:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 265C22DF94; Tue, 19 Dec 2023 15:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="OlczGLQw" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E696220DC4 for ; Tue, 19 Dec 2023 15:12:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BJ9wuhv017135; Tue, 19 Dec 2023 15:12:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=7NuuEtCagypjfe1xtc4mlaQysed4lhnQXPrzUeLCbiE=; b=OlczGLQwnNuot5L8T2BLKhFGkcOuWfvmwsZrjpY0iNulSNEp25TfcgnS/kvTVkOrmHEr lv+/pMfXjnEIW4ooY8eEgGZIoR4UHmKZuwiqtjKrgqTWx9GtucX+QUSXwWp183gH6k4C 2onrW5wCjMOspWus4QaCcz8g7+gIIXMpOEJ1TAydyXz3TX/vwDZLnFBYR+FsVUeyEAQL haX84pt94Pf511Iq3v+qZgFeCmSa9hxoJbBHwtl549UkXQ/Mz3toRPukRRNNmXW8B6to OeIhbAKab527mSXIdbr4NK+vp6HjYR6rZpIoD5CMCMDLd933kaaloewBzQy4gpe1Rt/B rg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3v12p465px-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Dec 2023 15:12:27 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3BJDuAKW028981; Tue, 19 Dec 2023 15:12:26 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3v12b6w7p2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Dec 2023 15:12:26 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BJF7SdV008899; Tue, 19 Dec 2023 15:12:26 GMT Received: from localhost.localdomain (dhcp-10-175-58-169.vpn.oracle.com [10.175.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3v12b6w71u-6; Tue, 19 Dec 2023 15:12:25 +0000 From: Vegard Nossum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, Brian Gerst , Peter Zijlstra , Linus Torvalds , Vegard Nossum Subject: [PATCH 5/5] x86: add DB flag to 32-bit percpu GDT entry Date: Tue, 19 Dec 2023 16:12:00 +0100 Message-Id: <20231219151200.2878271-6-vegard.nossum@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231219151200.2878271-1-vegard.nossum@oracle.com> References: <20231219151200.2878271-1-vegard.nossum@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-19_08,2023-12-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312190113 X-Proofpoint-GUID: 5IeiefAD5OtgnnxlBoEVhp68y83iybXq X-Proofpoint-ORIG-GUID: 5IeiefAD5OtgnnxlBoEVhp68y83iybXq X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785724028554361343 X-GMAIL-MSGID: 1785724028554361343 The D/B size flag for the 32-bit percpu GDT entry was not set. The Intel manual (vol 3, section 3.4.5) only specifies the meaning of this flag for three cases: 1) code segments used for %cs -- doesn't apply here 2) stack segments used for %ss -- doesn't apply 3) expand-down data segments -- but we don't have the expand-down flag set, so it also doesn't apply here The flag likely doesn't do anything here, although the manual does also say: "This flag should always be set to 1 for 32-bit code and data segments [...]" so we should probably do it anyway. Link: https://lore.kernel.org/all/CAHk-=wib5XLebuEra7y2YH96wxdk=8vJnA8XoVq0FExpzVvN=Q@mail.gmail.com/ Signed-off-by: Vegard Nossum --- arch/x86/kernel/setup_percpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c index f2583de97a64..b30d6e180df7 100644 --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c @@ -106,7 +106,7 @@ void __init pcpu_populate_pte(unsigned long addr) static inline void setup_percpu_segment(int cpu) { #ifdef CONFIG_X86_32 - struct desc_struct d = GDT_ENTRY_INIT(DESC_DATA32 & ~_DESC_DB, + struct desc_struct d = GDT_ENTRY_INIT(DESC_DATA32, per_cpu_offset(cpu), 0xFFFFF); write_gdt_entry(get_cpu_gdt_rw(cpu), GDT_ENTRY_PERCPU, &d, DESCTYPE_S);