Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1303050pxa; Sat, 15 Aug 2020 15:06:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEZEhuWOwR+hc0K30rwX6iTFEMaIc+cfNFwSgFCMWbHXUpOqdZFa+d1L6QKwev6r2DUXkV X-Received: by 2002:a17:906:413:: with SMTP id d19mr8899155eja.523.1597529184634; Sat, 15 Aug 2020 15:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597529184; cv=none; d=google.com; s=arc-20160816; b=LUfn7CwaZQX9qi+OceMFgaDwdof5MPsuGfyHSol8wSElj3LIk5lfRholUxJdzxmxYx aQr3oA4HYtmHX5GBzt/wR2xnIFwgs5JDCnbMxs5ORlG7HSsAs4R//SY5vyLZd3S9wMHu 4wSz0IJEDhPFPi+nkudIBoJTONdnVJh/pnQnCpZHvcP63gAWmZp/r+P7H4V9wYNH3z4Y Wag+Cuv4MwIWvtH74Viirp+CYtDYKZxSqSlOxuBs5M5u0EMHtAF3BFyjVR7waZ4ebegh 1tbmPYzN/DxjOPC1w2V0qTKh/75/mx8pVU2hHQgnNkMvCS0FN+AQ+uIc2CJgP38arr+2 EoAg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Sr87OpKcgqeQcj7Lut9VQ6DF03EgC9rXR/oozlPl9I0=; b=wApej9690MrIx9tytFin9hI94IB8ugmwFIGy3GFS3eGenDV75H6X/GrdmKG2WLbd1R iyG27cea4W1/9E8k/AyMLtkT8CeQNVmTKGVhqh+MlV+4zZVDNDcabUg0x2ZXokEI1WF1 TdG4uvpETyDqII6fldKFT5QE7sqc3N36NPsCv8sOb1S5C/yYvfKBNlrKm+Fbh62iHYkH 6TxDrvNgnCr9DlYfqsbwLip1d5UA2vn4OCpYGIGHDq7ZSukd1Ve2M3tTdrV4Ox8PFo8d e6NI6GjKNuPGQH8RR9eBrFAQwC3P6zCzL8hJTl9lunJxD/blaJqQ/bXShbsnLkD9d7fK TyiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=a0Rw2bBS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p15si7883623ejx.297.2020.08.15.15.06.01; Sat, 15 Aug 2020 15:06:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=a0Rw2bBS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729842AbgHOWE2 (ORCPT + 99 others); Sat, 15 Aug 2020 18:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728555AbgHOVvC (ORCPT ); Sat, 15 Aug 2020 17:51:02 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D02EC061374 for ; Fri, 14 Aug 2020 20:19:27 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id k18so8453649qtm.10 for ; Fri, 14 Aug 2020 20:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sr87OpKcgqeQcj7Lut9VQ6DF03EgC9rXR/oozlPl9I0=; b=a0Rw2bBSyqjyxtQEVYDJF5UDSoxnf31h9xYjxTorXrRsufS12jJhrWyPwlAQraVyu8 Eig+m2NceIZJfgxrM622A/TDW9fiqWVxjSN5/7SyLFyNmMcf0MOtJ79gBJCQzjMavIwi FHQNEoxMgoQZZuK3w0rBVgisOjO1HcfBwhA3o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sr87OpKcgqeQcj7Lut9VQ6DF03EgC9rXR/oozlPl9I0=; b=XA7dLx9g3LymuCJtEAPl6Hzg5vYNzKvChPOUPVZ1jn4ey7SQ9osW9kAzJDXb9nyMRE 43+Y42OZsL8qnd3MmFb7e+8HvrIpCZ4rRDSidSj8PBUO1DOZyU+tV5cj9sI+aWyv/rXq sTKKiGzNooUgbkCi72O9PLDprFHTrjnYEm/1jd/Nr9OARg/a3qw2XbFGxFv8zNWamjbA dYWDr+JFrifIsvo8CqxQ/uySs3/je4+taeUKNK/BOqewjJIzWInrp2SgzQ1g830nOtGx cKuNJ38pCs6ueWkZrFriY+0oXgPPsejPLdOSHr0Q77/hxQ0mWBzR7XJeUDck0JIFsbMc TlCQ== X-Gm-Message-State: AOAM530CVZBEWj9WTHU+iMt2FYz6inW51VcZhoDAwDjB1ma1RU8+ui4G I1SGczaCDqKPRKdD0wK56ItTygpm8je7YA== X-Received: by 2002:aed:3b57:: with SMTP id q23mr4961944qte.150.1597461565702; Fri, 14 Aug 2020 20:19:25 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id p12sm10055199qkk.118.2020.08.14.20.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 20:19:25 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Aaron Lu , Aubrey Li , Julien Desfossez , Kees Cook , "Paul E. McKenney" , Paul Turner , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Tim Chen , Tim Chen , Vincent Guittot , Vineeth Pillai , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), fweisbec@gmail.com, kerrnel@google.com, Phil Auld , Valentin Schneider , Paolo Bonzini , Chen Yu , Christian Brauner Subject: [PATCH RFC 03/12] arch/x86: Add a new TIF flag for untrusted tasks Date: Fri, 14 Aug 2020 23:18:59 -0400 Message-Id: <20200815031908.1015049-4-joel@joelfernandes.org> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog In-Reply-To: <20200815031908.1015049-1-joel@joelfernandes.org> References: <20200815031908.1015049-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new TIF flag to indicate whether the kernel needs to be careful and take additional steps to mitigate micro-architectural issues during entry into user or guest mode. This new flag will be used by the series to determine if waiting is needed or not, during exit to user or guest mode. Signed-off-by: Joel Fernandes (Google) --- arch/x86/include/asm/thread_info.h | 2 ++ kernel/sched/sched.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 267701ae3d86..42e63969acb3 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -98,6 +98,7 @@ struct thread_info { #define TIF_IO_BITMAP 22 /* uses I/O bitmap */ #define TIF_FORCED_TF 24 /* true if TF in eflags artificially */ #define TIF_BLOCKSTEP 25 /* set when we want DEBUGCTLMSR_BTF */ +#define TIF_UNSAFE_RET 26 /* On return to process/guest, perform safety checks. */ #define TIF_LAZY_MMU_UPDATES 27 /* task is updating the mmu lazily */ #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */ #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */ @@ -127,6 +128,7 @@ struct thread_info { #define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP) #define _TIF_FORCED_TF (1 << TIF_FORCED_TF) #define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP) +#define _TIF_UNSAFE_RET (1 << TIF_UNSAFE_RET) #define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) #define _TIF_ADDR32 (1 << TIF_ADDR32) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 3575edc7dc43..1901d11a6f41 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2680,3 +2680,9 @@ static inline bool is_per_cpu_kthread(struct task_struct *p) void swake_up_all_locked(struct swait_queue_head *q); void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait); + +#ifdef CONFIG_SCHED_CORE +#ifndef TIF_UNSAFE_RET +#define TIF_UNSAFE_RET (0) +#endif +#endif -- 2.28.0.220.ged08abb693-goog