Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp108514lqm; Mon, 10 Jun 2024 14:31:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+rt0599f2kIM4GX57iQnmn5qdtpMtN/DUVhsFvycILAX2l+Cn++zVBXaTLXpQ3Vapb0IZ5WZ7ignSSxNu1zXyjDkIZuHTQ+ucGyuQ5A== X-Google-Smtp-Source: AGHT+IFHOGibN1ZT1SI/6sl/4lj1QGf4xrZR3V/Luo0YiX1VYN2Z/I2eeS6WWNFKxKn+HIrfUmbf X-Received: by 2002:a17:902:d2c4:b0:1f7:1f4d:4652 with SMTP id d9443c01a7336-1f71f4d46b0mr22141575ad.25.1718055091208; Mon, 10 Jun 2024 14:31:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718055091; cv=pass; d=google.com; s=arc-20160816; b=EpA+ZRR1z7rAZBOs3d1dWFHMKF7EMb62pWVfo34cBnYKdxTZ+D/9GYpBn+XmnoPDnJ 2aSGEzfrle5q1kMa38k9RsXbjBJctZBW/9SIDjy/5My0QjjkwWY6xwsVeqwM/l0weV7o QH8Qkny9GmI+TteORlVy5H4ZyZylo8C8oClbGFrHpRQEVc/AGriThf/L5ptvsjstXKn+ wzQ4plvHM5fQe2I+9zUXoRglOsc3pp9kyGPdX600xcNIWFep1tKQNpG1hdn41RYOkZk9 g8q7EQm/cLUE5WkHc731DTU3WFpCydCwO+s54WM2Rc+rn+UtcBrcowDPURpOHCpRGhIa bnVg== ARC-Message-Signature: i=2; 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=srmtWDLn7HyLT5YaIX7R6X8HCxfXWwh3FOO5Hc8ZZKc=; fh=62uYJ6xVc0ZuohFHRNxtj6wEusMjPNXO6tSlc1XZ3Kg=; b=PcNSMBqO0WB7a1cMEFCV9QwpRAd7SfoBnCBSFbmvEz2KUEVPvp/0Aokvml6E6B4+s+ 9OHzl0gL3LqA7tGZMeW4eNzBl4xpsfei5Vqy+x4aeld+b40cRJ6Qb7OPRDos38vptbAZ BGebhZQUaLhK6ZKiKX83+9JH6DzH5zfiEPutnpL+SpviYU8l78swM1t0uS0U67Rf0dQV 4vpD5zwb3l2YGQCkCSdoaKSB3B1OaOkPD9lzkDcE7cd3hd3OCQcTMA3+lSU+yVO4oe+k Q+YVNF9OAlErkyCcBscuafZefSy7/aPdyNR2LQpV3XfU/+LS1e72tqcijpNaQXFt395P B+HQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mBvbdPYE; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-208917-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208917-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f730bbb2c3si490755ad.167.2024.06.10.14.31.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 14:31:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208917-linux.lists.archive=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=@chromium.org header.s=google header.b=mBvbdPYE; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-208917-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208917-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 C981D283012 for ; Mon, 10 Jun 2024 21:31:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24C076F2FC; Mon, 10 Jun 2024 21:31:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="mBvbdPYE" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2B3E1CF8D for ; Mon, 10 Jun 2024 21:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718055085; cv=none; b=AR7UxerQWOzvPmnyHDohFlXmCCYshUGO6Dxeq5J2PIYDMBq14RS3bdHoN9BjE8uITqPjHFbP+q7S81ZR0rEqrZ6AB1N2fzssmO1rj8keCHdf3NmIXqsBd8T6a0iduwRhUMu53rOfqTIPZR0CloiyAYIcbehfOgIqxbkxHgX5WJE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718055085; c=relaxed/simple; bh=SfluqvPw18zZm21EjL8PZD3dt2e7CnA/7EwXFgI2ZfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PyFPDV24zBYztVJxeCpTTEOxvT9JlZvAA8cyKrOPtnp93P0lH+wFCoSptV9cXfjNld6MjQz5EXiAstGc4dR85PmYlMVI9sYHUB3hTk6loftw0s+jREP5ScfPwKhgjbb2PXfARJLxAAOxajXErXqgJE/Ctzvs6GfegObubPi8wnc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=mBvbdPYE; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-70255d5ddc7so402421b3a.3 for ; Mon, 10 Jun 2024 14:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718055083; x=1718659883; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=srmtWDLn7HyLT5YaIX7R6X8HCxfXWwh3FOO5Hc8ZZKc=; b=mBvbdPYE6AncRM6LROibfSdwHxjiGGBCk3a9G0uHPEf0TuKY78w24qL1EfhrydiPKE lXlo010WVh2hUasiQtjHVFzHi2V/AeDlG64UDbA9aa8gyxIrQ0nXDryT1zZ6XaNJH9Sy WZCSSaNzrr613hsit+PpEZAKfjKF4zU5iYZRY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718055083; x=1718659883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=srmtWDLn7HyLT5YaIX7R6X8HCxfXWwh3FOO5Hc8ZZKc=; b=AI+gQUknzuRVjDr5cmuPvFBS/1AfMa4/Zv5YKzk/PvByD5XCiZos2ITmS8KdI82QrJ 0Qwsp1xTm8mIy8r+ntZqlG5Qpmak1MJO01szl79Gur1Ljod6DwnhCUnStjA4WlEZeWdG tERolqTs85I9NOKGgt0I3yiKZxsg+AlLNeDtMKy4hts/UCCpKNDZDyD/NqT5ltUbZcGf guOxpdTjW4cfcGKtHnbnXuPWq+QhA4OqHChQuX9yQrP0EZkew/HWYkpjcx60eCOIRj99 g3UydhOgGadT/Fu8OQx70F2wcYmBVUaC5ng7DgvV2o8+0ZZELF7EjdwL4c798R8NgU1j yvVg== X-Forwarded-Encrypted: i=1; AJvYcCUgz5JYXwF75kZtScdFbNcfeKe4tu8WTaRVJvkWirBbbUm+h0ip9oZPAzzIAXk3Gwrl0pgs6imKblpejkZblKYlJJq1IMsmmD+gjuIi X-Gm-Message-State: AOJu0YwDUXaaCrUwh2P0BYJ/P2atxb9/ivfBemSDUif5oZYhYJrGRfYT zYDCZmjfkulNq0UbEYzU8dx23cl8pDVeO7WrN2tip7jasClHIgXBvrorbwa1Yg== X-Received: by 2002:aa7:8881:0:b0:703:fe89:6ebe with SMTP id d2e1a72fcca58-7040c74a67dmr11332032b3a.29.1718055082850; Mon, 10 Jun 2024 14:31:22 -0700 (PDT) Received: from localhost (213.126.145.34.bc.googleusercontent.com. [34.145.126.213]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-703fd50beb6sm7401469b3a.176.2024.06.10.14.31.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jun 2024 14:31:22 -0700 (PDT) From: jeffxu@chromium.org To: aruna.ramakrishna@oracle.com Cc: dave.hansen@linux.intel.com, keith.lucas@oracle.com, linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de, x86@kernel.org, andrew.brownsword@oracle.com, matthias.neugschwandtner@oracle.com, jeffxu@chromium.org, jeffxu@google.com, jannh@google.com, keescook@chromium.org, sroettger@google.com, jorgelo@chromium.org, rick.p.edgecombe@intel.com Subject: Re [PATCH v5 1/5] x86/pkeys: Add PKRU as a parameter in signal handling functions Date: Mon, 10 Jun 2024 21:31:22 +0000 Message-ID: <20240610213122.3377462-1-jeffxu@chromium.org> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240606224035.3238985-2-aruna.ramakrishna@oracle.com> References: <20240606224035.3238985-2-aruna.ramakrishna@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Thu, Jun 06, 2024 at 10:40:31PM +0000, Aruna Ramakrishna wrote: > diff --git a/arch/x86/include/asm/sighandling.h b/arch/x86/include/asm/sighandling.h > index e770c4fc47f4..de458354a3ea 100644 > --- a/arch/x86/include/asm/sighandling.h > +++ b/arch/x86/include/asm/sighandling.h > @@ -17,11 +17,11 @@ void signal_fault(struct pt_regs *regs, void __user *frame, char *where); > > void __user * > get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size, > - void __user **fpstate); > + void __user **fpstate, u32 pkru); > > -int ia32_setup_frame(struct ksignal *ksig, struct pt_regs *regs); > -int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs); > -int x64_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs); > -int x32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs); > +int ia32_setup_frame(struct ksignal *ksig, struct pt_regs *regs, u32 pkru); > +int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs, u32 pkru); > +int x64_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs, u32 pkru); > +int x32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs, u32 pkru); Does ia32 support PKEY ? I thought it is X64 only. It might be possible to not to change any of ia32 code. > > #endif /* _ASM_X86_SIGHANDLING_H */ > diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c > index 247f2225aa9f..2b3b9e140dd4 100644 > --- a/arch/x86/kernel/fpu/signal.c > +++ b/arch/x86/kernel/fpu/signal.c > @@ -156,7 +156,7 @@ static inline bool save_xstate_epilog(void __user *buf, int ia32_frame, > return !err; > } > > -static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf) > +static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf, u32 pkru) > { > if (use_xsave()) > return xsave_to_user_sigframe(buf); > @@ -185,7 +185,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf) > * For [f]xsave state, update the SW reserved fields in the [f]xsave frame > * indicating the absence/presence of the extended state to the user. > */ > -bool copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) > +bool copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size, u32 pkru) > { > struct task_struct *tsk = current; > struct fpstate *fpstate = tsk->thread.fpu.fpstate; > @@ -228,7 +228,7 @@ bool copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) > fpregs_restore_userregs(); > > pagefault_disable(); > - ret = copy_fpregs_to_sigframe(buf_fx); > + ret = copy_fpregs_to_sigframe(buf_fx, pkru); > pagefault_enable(); > fpregs_unlock(); > > diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c > index 31b6f5dddfc2..94b894437327 100644 > --- a/arch/x86/kernel/signal.c > +++ b/arch/x86/kernel/signal.c > @@ -74,7 +74,7 @@ static inline int is_x32_frame(struct ksignal *ksig) > */ > void __user * > get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size, > - void __user **fpstate) > + void __user **fpstate, u32 pkru) > { > struct k_sigaction *ka = &ksig->ka; > int ia32_frame = is_ia32_frame(ksig); > @@ -139,7 +139,7 @@ get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size, > } > > /* save i387 and extended state */ > - if (!copy_fpstate_to_sigframe(*fpstate, (void __user *)buf_fx, math_size)) > + if (!copy_fpstate_to_sigframe(*fpstate, (void __user *)buf_fx, math_size, pkru)) You might find that we only need to update PKRU right before copy_fpstate_to_sigframe, so no need to pass pkru all the way from top. -Jeff