Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5303799imm; Wed, 12 Sep 2018 04:13:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZoE0H/NwHbtWv2bDbOmBirJRjQL0+uWPoA5va6Jl03ud5MQ2090e0JNlbLJI2iik31ar8l X-Received: by 2002:a63:f111:: with SMTP id f17-v6mr1603176pgi.87.1536750828574; Wed, 12 Sep 2018 04:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536750828; cv=none; d=google.com; s=arc-20160816; b=a8WkbL+JFgz6sZ1mBuyxFruCN24KW6tnwpFBjSFfNyZBKYoOVwVZsJ4vVE2uiFWLM8 yxMM/247uM9yuMDARUOyZ0QyWPNCY6FgqTrFIRU/2t0crSSP1WnU2hOyjKfcv9q07qlf SIIDh7mXHW/KDkK1pF4uID/O9LjpJVKYIO6iFGkNXkqXjuT2sL3pQ7sOkKayUuBiZg3Z 8bbp4fmphDmQp4JhbfNNPUo7ZIB3byBMNz6wrs421BdFasSEE4NVmzqW2xC0JqQVE7kd 4KC5J6uEflU0m5FzIWUtczpFFWSmSBA6VA4wqukdTRCrtOwT3wJZk89bF9rL3AkK5CML wjHg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=4DNQEBcBJVYdVLxXv4K2ydzISVIOm5+twq9A5/Qh/gM=; b=QY2X1DkGvEQ4s4oJroZJvyM2MIDkmuxtkEQfXsDnDSuOKf0rh05H+pzpa24/Uvd/Md 0Dq7opmIawSNc8A/MMkEFhA04V5ZnmfGX3aMgswsGNefm0GL4lrMr9vPXyg/Z2RMjxzq n7Z4TANQzHjg1iHaiSpXHZHoGlk/LUgN4dU9CJwdhbGciX5iwc+58sWr6PkcjzevD3/i hksxJelsfhbzXkDJu7kErU5UOgfJI54GeGiTspKeyIvjcCQovNpH9Xgzg6UfuSIAQBSi CqT6S7nI1sLnBS8TaSoqhM0vwIkVk9zghU5jP4duHURXAVvOdPc2ZyCnhu6Wh+VhOgcs xoEg== 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 j61-v6si663471plb.49.2018.09.12.04.13.33; Wed, 12 Sep 2018 04:13:48 -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 S1728033AbeILQPW (ORCPT + 99 others); Wed, 12 Sep 2018 12:15:22 -0400 Received: from foss.arm.com ([217.140.101.70]:57670 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbeILQPV (ORCPT ); Wed, 12 Sep 2018 12:15:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EC6217A9; Wed, 12 Sep 2018 04:11:18 -0700 (PDT) Received: from [10.4.13.92] (e112298-lin.Emea.Arm.com [10.4.13.92]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4B0B13F614; Wed, 12 Sep 2018 04:11:17 -0700 (PDT) Subject: Re: [PATCH v5 05/27] arm64: Use daifflag_restore after bp_hardening To: James Morse Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, joel@joelfernandes.org, marc.zyngier@arm.com, mark.rutland@arm.com, christoffer.dall@arm.com, catalin.marinas@arm.com, will.deacon@arm.com References: <1535471497-38854-1-git-send-email-julien.thierry@arm.com> <1535471497-38854-6-git-send-email-julien.thierry@arm.com> <641119b9-3466-817d-3d6b-dd710c646b49@arm.com> From: Julien Thierry Message-ID: <8f200315-1db9-1905-71ae-cb4269450b7c@arm.com> Date: Wed, 12 Sep 2018 12:11:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <641119b9-3466-817d-3d6b-dd710c646b49@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi James, On 12/09/18 11:32, James Morse wrote: > Hi Julien, > > On 28/08/18 16:51, Julien Thierry wrote: >> For EL0 entries requiring bp_hardening, daif status is kept at >> DAIF_PROCCTX_NOIRQ until after hardening has been done. Then interrupts >> are enabled through local_irq_enable(). >> >> Before using local_irq_* functions, daifflags should be properly restored >> to a state where IRQs are enabled. > >> Enable IRQs by restoring DAIF_PROCCTX state after bp hardening. > > Is this just for symmetry, or are you going on to add something to the daifflags > state that local_irq_* functions won't change? (if so, could you allude to that > in the commit message) > What happens is that once we use ICC_PMR_EL1, local_irq_enable will not touch PSR.I. And we are coming back from an entry where PSR.I was kept to 1 so local_irq_enable was not actually enabling the interrupts. On the otherhand, restore will affect both. Another option is to have the asm macro "enable_da_f" also switch to PMR usage (i.e. "just keep normal interrupts disabled"). Overall it would probably be easier to reason with, but I'm just unsure whether it is acceptable to receive a Pseudo NMI before having applied the bp_hardening. If it is possible, I'm happy to solve this with enable_da_f. Thanks, > > Either way, > > Acked-by: James Morse > -- Julien Thierry