Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1386003pxa; Sat, 15 Aug 2020 18:46:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl8gmJBMbCDnUZwva+i5SKwwB3c2xmAKP+GM9EmTYyhoO/QukjCJIUbqV0px1RsiDImlAh X-Received: by 2002:a17:906:3b97:: with SMTP id u23mr9383998ejf.31.1597542383498; Sat, 15 Aug 2020 18:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597542383; cv=none; d=google.com; s=arc-20160816; b=RwAFxk7EJ74cKJFkfk+asORm+QYoWDGj6QEIJjlPbzUCk1b+9Ms0Mn+FfkuErZ2IaR 6/rTBl7gE6QIEEDjtHm2silffwkN+Jeu+6PLNAjvkn8B+K0tCLxGJLc3hwsGaiQqejmw HSxFdLb3L+5lyJrwqUDR1wK+Y2vyuH3fYnJHf15ZfpvAbr5gJLzqHYL8AhEyn/j3bW3k fAtdLPgKCgP14MYJ2kVGZXBw5ejsBKV0VXdRmVEBEhG2+lEuU7yMdBTC2KJW5QRYOGdK 6DzCNBczMxn5I6rJwiarzsicbBXFP1hj7TFP9u4SS9pCVmkJrCqTQYq+EPbCu8Vje17g VMow== 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=G4c3X4fa7A0Cg+XAPQyHWHEQy+O3UWxNni7PmaUnDAE=; b=dhWsRsYn8NTkFj9fvmWtluuRzLlvhOBPVwmnvxzFO8NYosOSN9/TOemGJwZuI1t3KK Rc+cNCxKqHxBOoWol23rfgpJydrLUlw+uu6EqR0cJbjKAVIesWnmdF77RE+BzHnnxyHB wjsDcjman7HYItrZkliXkX6fUj1z/WDVLkxgSrUOUmkqs4x7/Xbpo4leDjJEUK8wMSKZ 9h3vuqVraQi9AACjYcnVqTteBqIXxm+LmRTgPkdCRbqjQuhAA5PO9eyn2ToeKRo21OOS ZjQ7fJ41XBnTU2LDfowH3DIrTNmyFzAgocr4gfEIEl6m4rdNgrypJtT6cviPymLEeheB 8kAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=XqLHbguh; 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 e8si8041558eja.31.2020.08.15.18.46.01; Sat, 15 Aug 2020 18:46:23 -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=XqLHbguh; 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 S1729009AbgHOV5J (ORCPT + 99 others); Sat, 15 Aug 2020 17:57:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728931AbgHOVwJ (ORCPT ); Sat, 15 Aug 2020 17:52:09 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76624C061376 for ; Fri, 14 Aug 2020 20:19:29 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id cs12so5254396qvb.2 for ; Fri, 14 Aug 2020 20:19:29 -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=G4c3X4fa7A0Cg+XAPQyHWHEQy+O3UWxNni7PmaUnDAE=; b=XqLHbguhqoEPspyNp4hmZ+InRFZrVuqPCt2M/ZX9lbgbDxd0fJ6lELOB9Tmfjw2e2i e0XlZUbVd6dwFw2bs6GxDj7WMO/UaAEg5ft9wK2nj1eo2zxgqEV5cbDnS/nRvDlqydjg Qv4DYyPVJ8b/lF6ofhoYpaJClXg4UUL24hlPI= 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=G4c3X4fa7A0Cg+XAPQyHWHEQy+O3UWxNni7PmaUnDAE=; b=DDqhDaL/VFOQpwCEF18NugGyzGFi/nRuYXa/e6FJzaNNR3O6MdhfszB37KVIOYXNFm 7lIdTqvQ0F6iN4SeonuXdEuW2AxHvq5DtDr+F5R0XKSK5PlA5Xqo/7PkhIK/5sPvCqS2 NdmXxiP93d6yjzq9W4EjM2ygq+nLGBu19p/8QiX3+w0he3RpcKWxph3BqENhgsKRKTay BKwFmA/Iu7ah+M7QtKPYg9XeYKc00aRUPF34iEpolP/y4i3Sf59SqhMe19eUmVHIojmg lLxvfkix7HHae87D1Wul3zp8D0gIJwLwcixi7Qi3fG4zprLlrFb9LXO9UpfPlYS3gf94 GVQg== X-Gm-Message-State: AOAM533Z+W5MogaYViIOZdTIP3srdJaMfLCYrNxZqqgN3EnlA3uUyiS5 JQZv2tGTAlMOUVOvHAexkBmfize8rHBuRw== X-Received: by 2002:a0c:99c8:: with SMTP id y8mr5477118qve.57.1597461568034; Fri, 14 Aug 2020 20:19:28 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 20:19:27 -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 05/12] entry/idle: Enter and exit kernel protection during idle entry and exit Date: Fri, 14 Aug 2020 23:19:01 -0400 Message-Id: <20200815031908.1015049-6-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 Make use of the generic_idle_{enter,exit} helper function added in earlier patches to enter and exit kernel protection. On exiting idle, protection will be reenabled. Signed-off-by: Joel Fernandes (Google) --- include/linux/entry-common.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 2ea0e09b00d5..c833f2fda542 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -374,6 +374,9 @@ void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state); */ static inline void generic_idle_enter(void) { + /* Entering idle ends the protected kernel region. */ + sched_core_unsafe_exit(); + rcu_idle_enter(); } @@ -383,6 +386,9 @@ static inline void generic_idle_enter(void) static inline void generic_idle_exit(void) { rcu_idle_exit(); + + /* Exiting idle (re)starts the protected kernel region. */ + sched_core_unsafe_enter(); } #endif -- 2.28.0.220.ged08abb693-goog