Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1919315yba; Fri, 10 May 2019 03:22:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0k7jeqiF40eq1WmiPwETLxGQ1JKqJfQHrG2o/9cO4rX/Xm0Kf1zC8/VJrruypOOh9CFq7 X-Received: by 2002:a17:902:50ec:: with SMTP id c41mr11998173plj.244.1557483732790; Fri, 10 May 2019 03:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557483732; cv=none; d=google.com; s=arc-20160816; b=i0phNCxJOeK7t3BznTqFHJSQSovqFZ8myl156KtUM5EOZjOkDz3/1HO7bs2HCM9JWB UqKy6z255+2+A1mHp25hndGIc2wMRgbZCbKAwNkI4xWUDJC6bsm3dm5YmrKpAcaEs1xC OoqTrgjvy2Yx2TntbLHp3DJ6r72RfwZXZo8+H9A0S18myT6HiI5g0pO8dRsz/0TwcRWG QVjqb0jWbX1ViA9icVcBSktCHyNCGZhNUHTVH+GyTP+FRfINOLhHKqPceelpi44CWvWi nWjaCYTqVSLZ0MpVNLTI4RwFZO5dFl8G9arrIBaUzCf/txneLREn58rJC88i7YbeZaqw bdTQ== 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 :message-id:date:references:in-reply-to:subject:cc:to:from; bh=fjLxfx8fRvo84pl/3QqgMeWYiQjGpEOPuflUfiMQMd8=; b=M7g1m3xE59wMFWjdleNnXQh3rNqvRUQS1CiKJVDYLZV37fzPstSmwrGr6HPG9ekcqF C/S7nPkv+8Uo9Y1G2Dev02gHfroFgjRjtCiAalnqRm3CWTvUORhVvqSQXHQGRWcuZBjZ XjqvsEr2EJaeYPz1p5xkVz+6XlexisUMA72lET5bco9RuJvpF0RS1HjrDxjzmWNnLFaz GM9McUSkBXdB2l6fSYAAJiWINUanfHnuAPxbCGVbtfOUs+vGLjZlY/6MrGCv/wLFV0v8 8AUkxMq+GDC5bDBQDmZWT74r6sUqEH8xDyKgoXHWIu8/sOa2cc1WZWXdJ/88WNy56a3L g3gg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si6188784pgw.359.2019.05.10.03.21.56; Fri, 10 May 2019 03:22:12 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727420AbfEJKVI convert rfc822-to-8bit (ORCPT + 99 others); Fri, 10 May 2019 06:21:08 -0400 Received: from ozlabs.org ([203.11.71.1]:44463 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727053AbfEJKVH (ORCPT ); Fri, 10 May 2019 06:21:07 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 450mSt2tmqz9sD4; Fri, 10 May 2019 20:21:02 +1000 (AEST) From: Michael Ellerman To: David Laight , 'Michal =?utf-8?Q?Such=C3=A1ne?= =?utf-8?Q?k'?= , Petr Mladek Cc: Linus Torvalds , "linux-arch\@vger.kernel.org" , Sergey Senozhatsky , Heiko Carstens , "linux-s390\@vger.kernel.org" , Rasmus Villemoes , "linux-kernel\@vger.kernel.org" , Steven Rostedt , Michal Hocko , Sergey Senozhatsky , Stephen Rothwell , Andy Shevchenko , "linuxppc-dev\@lists.ozlabs.org" , Martin Schwidefsky , "Tobin C . Harding" Subject: RE: [PATCH] vsprintf: Do not break early boot with probing addresses In-Reply-To: <8ad8bb83b7034f7e92df12040fb8c2c2@AcuMS.aculab.com> References: <20190509121923.8339-1-pmladek@suse.com> <20190509153829.06319d0c@kitsune.suse.cz> <8ad8bb83b7034f7e92df12040fb8c2c2@AcuMS.aculab.com> Date: Fri, 10 May 2019 20:21:02 +1000 Message-ID: <87ef56vcdt.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org David Laight writes: > From: Michal Suchánek >> Sent: 09 May 2019 14:38 > ... >> > The problem is the combination of some new code called via printk(), >> > check_pointer() which calls probe_kernel_read(). That then calls >> > allow_user_access() (PPC_KUAP) and that uses mmu_has_feature() too early >> > (before we've patched features). >> >> There is early_mmu_has_feature for this case. mmu_has_feature does not >> work before patching so parts of kernel that can run before patching >> must use the early_ variant which actually runs code reading the >> feature bitmap to determine the answer. > > Does the early_ variant get patched so the it is reasonably > efficient after the 'patching' is done? No they don't get patched ever. The name is a bit misleading I guess. > Or should there be a third version which gets patched across? For a case like this it's entirely safe to just skip the code early in boot, so if it was a static_key_false everything would just work. Unfortunately the way the code is currently written we would have to change all MMU features to static_key_false and that risks breaking something else. We have a long standing TODO to rework all our feature logic and unify CPU/MMU/firmware/etc. features. Possibly as part of that we can come up with a scheme where the default value is per-feature bit. Having said all that, in this case the overhead of the test and branch is small compared to the cost of writing to the SPR which controls user access and then doing an isync, so it's all somewhat premature optimisation. cheers