Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FA7DC43331 for ; Mon, 30 Mar 2020 21:11:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B36020714 for ; Mon, 30 Mar 2020 21:11:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SCKjDTUh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qkUwoL/p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B36020714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PcZaEKWY/tUs5DS4Yl4yiGRCQE8FYxudnZE4we7Jwi0=; b=SCKjDTUh7FScas rEcATHybn7kJRH2Ape5eVYzqquJqPxKgInGzIV3z6iOizYkIWe+GmwQm4xsD/DcVFBWvBC8PjjMU9 2g7+O7LMrx5Chf7KWawKkbs/iNXZAOoIk+6C3EEm1iN6hP4qtQXPTdVXgmzD7Idy6LZ66eYrWH04c ItxTsv8fLFe/ZnGo8xp+ENIaJoYtmjKVvXazCSGEq6i8io7Eh1p2fBPILboz1GlSfBHGcgA0QpavJ jNAFVByy++0ejsUvnCG4XTfl6htHhc0WnjG/f8DEaIRYl+OhK6LbAl/E2yhh1MaJ2+QhPPTVCGWUw ug1JNFIt7Fe2AmSIQK0A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJ1gs-0001pa-3t; Mon, 30 Mar 2020 21:11:26 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJ1gp-0001p5-FY for linux-arm-kernel@lists.infradead.org; Mon, 30 Mar 2020 21:11:25 +0000 Received: by mail-wr1-x444.google.com with SMTP id m11so17556150wrx.10 for ; Mon, 30 Mar 2020 14:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=fsMl5Nx+EmTAuVrV9vWYdHUKz0NPKJDPN8ZitH6IpPE=; b=qkUwoL/pZpNky35c/1heq+TyyXk76VwNKaEr1hnORbKxg6AifweZU0gpxO8jA06G0g kBUcotah/TksaORVep4cWKxInrUhdyTgHnJ4XX8BsmUDZ1dKX1TKivwFfT4s2MRGziLf BniGMW8MjNEAevgj35p4FJh0iOrl18jvgGbB9dy8fBWZ8qsm/KSKPiUcXZE04BOJF7TH t+PN0iUPxboJbqVCRAK6sfzSAdXGJ/SNY0EaTPKiCFMwFzygLQi3dFMJM0FUkZpBJ84D qZ2FH+HqeQXfa7tBaO7l3srKybnSMtrR0DhLzvqAMKpWCKPQ4seU1yLxb2R567xTXGp8 hXDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=fsMl5Nx+EmTAuVrV9vWYdHUKz0NPKJDPN8ZitH6IpPE=; b=scD+Y1CoIl7laPiOGuKJsreyCkXWx7XjXUw1tPpVxyYJGoQJ+ME3K5pGUw+V3+rfCv FhLBFvJI8kMxVIh1Y7ggegiDKbtqcvpkBnslKH215+EPbUaSJ5oa3Wwj13Cwcz+TvEi4 cW5VgcvPm1w8qj4exaizadIHGGB4yB7wxIv4kznCq0FrcoR8TX4SjVKwAAdqJhL2OZXT thqnTJrSfxlIIonx7CkYim0gVzp2YYlJhd+azuZTOVMGKiY8FpnO2u3kz7k1NW6Sc9RP 6EYtebFi5ViYr2JfmzFbz0A6Ifz7KTKAcwchPxxRaQTlDKtfx/FQIbsm9L5uQqIijISq zvlQ== X-Gm-Message-State: ANhLgQ2KdPqapjzZz2LLVqrFx38yimGz2ihnRvHHfw8WSPi2yE5zBWiA 779e8CM8O+O5aSZey0tGMBw= X-Google-Smtp-Source: ADFU+vvsYHnRX7IEvIIMdR8GrBNGvueoR0/NcEXuTRZwvHiDR7fZcjquBNqjCupdEmDY7SFnUCh5fg== X-Received: by 2002:a05:6000:1205:: with SMTP id e5mr17875819wrx.73.1585602681914; Mon, 30 Mar 2020 14:11:21 -0700 (PDT) Received: from [10.230.186.223] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id x1sm911555wmj.24.2020.03.30.14.11.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Mar 2020 14:11:21 -0700 (PDT) Subject: Re: SError handling vs. SIGSEGV To: James Morse References: <3da89354-78f7-5f48-9eec-75c74270fa3e@gmail.com> <68580476-eba8-2615-c25f-f3f1b53118e0@arm.com> From: Florian Fainelli Autocrypt: addr=f.fainelli@gmail.com; keydata= mQGiBEjPuBIRBACW9MxSJU9fvEOCTnRNqG/13rAGsj+vJqontvoDSNxRgmafP8d3nesnqPyR xGlkaOSDuu09rxuW+69Y2f1TzjFuGpBk4ysWOR85O2Nx8AJ6fYGCoeTbovrNlGT1M9obSFGQ X3IzRnWoqlfudjTO5TKoqkbOgpYqIo5n1QbEjCCwCwCg3DOH/4ug2AUUlcIT9/l3pGvoRJ0E AICDzi3l7pmC5IWn2n1mvP5247urtHFs/uusE827DDj3K8Upn2vYiOFMBhGsxAk6YKV6IP0d ZdWX6fqkJJlu9cSDvWtO1hXeHIfQIE/xcqvlRH783KrihLcsmnBqOiS6rJDO2x1eAgC8meAX SAgsrBhcgGl2Rl5gh/jkeA5ykwbxA/9u1eEuL70Qzt5APJmqVXR+kWvrqdBVPoUNy/tQ8mYc nzJJ63ng3tHhnwHXZOu8hL4nqwlYHRa9eeglXYhBqja4ZvIvCEqSmEukfivk+DlIgVoOAJbh qIWgvr3SIEuR6ayY3f5j0f2ejUMYlYYnKdiHXFlF9uXm1ELrb0YX4GMHz7QnRmxvcmlhbiBG YWluZWxsaSA8Zi5mYWluZWxsaUBnbWFpbC5jb20+iGYEExECACYCGyMGCwkIBwMCBBUCCAME FgIDAQIeAQIXgAUCVF/S8QUJHlwd3wAKCRBhV5kVtWN2DvCVAJ4u4/bPF4P3jxb4qEY8I2gS 6hG0gACffNWlqJ2T4wSSn+3o7CCZNd7SLSC5BA0ESM+4EhAQAL/o09boR9D3Vk1Tt7+gpYr3 WQ6hgYVON905q2ndEoA2J0dQxJNRw3snabHDDzQBAcqOvdi7YidfBVdKi0wxHhSuRBfuOppu pdXkb7zxuPQuSve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KCRCH0Jac RAcHBIkHD/9nmfog7X2ZXMzL9ktT++7x+W/QBrSTCTmq8PK+69+INN1ZDOrY8uz6htfTLV9+ e2W6G8/7zIvODuHk7r+yQ585XbplgP0V5Xc8iBHdBgXbqnY5zBrcH+Q/oQ2STalEvaGHqNoD UGyLQ/fiKoLZTPMur57Fy1c9rTuKiSdMgnT0FPfWVDfpR2Ds0gpqWePlRuRGOoCln5GnREA/ 2MW2rWf+CO9kbIR+66j8b4RUJqIK3dWn9xbENh/aqxfonGTCZQ2zC4sLd25DQA4w1itPo+f5 V/SQxuhnlQkTOCdJ7b/mby/pNRz1lsLkjnXueLILj7gNjwTabZXYtL16z24qkDTI1x3g98R/ xunb3/fQwR8FY5/zRvXJq5us/nLvIvOmVwZFkwXc+AF+LSIajqQz9XbXeIP/BDjlBNXRZNdo dVuSU51ENcMcilPr2EUnqEAqeczsCGpnvRCLfVQeSZr2L9N4svNhhfPOEscYhhpHTh0VPyxI pPBNKq+byuYPMyk3nj814NKhImK0O4gTyCK9b+gZAVvQcYAXvSouCnTZeJRrNHJFTgTgu6E0 caxTGgc5zzQHeX67eMzrGomG3ZnIxmd1sAbgvJUDaD2GrYlulfwGWwWyTNbWRvMighVdPkSF 6XFgQaosWxkV0OELLy2N485YrTr2Uq64VKyxpncLh50e2RnyAJ9Za0Dx0yyp44iD1OvHtkEI M5kY0ACeNhCZJvZ5g4C2Lc9fcTHu8jxmEkI= Message-ID: <2506b851-8ee2-dca5-82ac-b06c0d406c6d@gmail.com> Date: Mon, 30 Mar 2020 14:11:17 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <68580476-eba8-2615-c25f-f3f1b53118e0@arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200330_141123_526346_FE2498AF X-CRM114-Status: GOOD ( 29.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Doug Berger , Scott Branden , Catalin Marinas , bcm-kernel-feedback-list@broadcom.com, Ray Jui , Will Deacon , Dave.Martin@arm.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 3/30/2020 4:30 AM, James Morse wrote: > Hi Florian, > > (I assume this is all on some pre-v8.2 system) Cortex-A53, so yes. > > On 3/28/20 4:31 AM, Florian Fainelli wrote: >> Up until commit e4ba15debcfd27f60d43da940a58108783bff2a6 ("arm64: >> fix for bad_mode() handler to always result in panic") we had been >> getting SIGSEGV delivered to applications running on Broadcom STB >> platforms which access register holes or registers for which we have >> purposely blocked the access via the GISB (proprietary bus for control >> registers) bus arbiter used on those SoCs. > > User-space has access to this? Not good. This is a test case that uses busybox's devmem (opens up /dev/mem), we do not expect anyone in production to do that. > > >> That commit arguably plugged >> a hole in that scheduling was possible when panic() was intended, so >> this is not really the only culprit. > >> We are actually relying on this >> behavior to pass a number of tests that specifically exercise that >> register blocking is effective without taking down the whole system. > > ... but this isn't actually possible ... > > The abort is asynchronous, the CPU may be doing something else when it arrives. > It may have taken an IRQ. Taking a (pre-v8.2) SError out of IRQ context has to > fatal. I suppose we have been lucky before in that we only ever saw the offending application being killed. > > >> Due to our SoC integration all of those register access errors are >> SErrors with the signature at the bottom. > > Do you trust user-space not to access them? > > If not, don't give user-space access to those pages! As I described, this is an intentional test case that exercises a bus firewall feature, this is not necessarily representative of a real world scenario. > > >> Doug had tried to submit a patch series that allowed a given platform to >> install custom abort handlers, similar to what ARM 32-bit permits, but >> this got shot down: > > For good reason. You cannot know that the abort was caused by your broken > hardware, and not an ECC error for the stack memory... ECC are separate syndromes which are actually known to the kernel. > > Getting this wrong leads to data corruption, and you have no reliable > information to base the decision on. (see below). The RAS extensions added the > CPU and system bits to improve this. The GISB bus does capture invalid accesses, that is the basis for this driver: drivers/bus/brcmstb_gisb.c which is helpful in identifying a block that is clock gated for instance. This would work too in the case where a register address is intentionally blocked out. > > >> I understand that such a SError is deemed catastrophic and >> unrecoverable, but taking down the whole system for something we could >> possibly resolve with a SIGSEGV provided the platform is known and hooks >> are in place would be more desirable IMHO, otherwise we have nice DoS >> lurking around and hard to debug systems in production, too. > > SError is asynchronous. The ELR_EL1 value is meaningless. > The CPU can change exception level between the access that triggers the > external-abort being sent, and the result received. You can't even rely on > 'while my process is running'. > > SError can also be imprecise so you can't return from an SError exception. The > CPU is not obliged to put the world back in order before taking the exception. > > precise/imprecise isn't commonly described. The arm-arm has: G1.3.4 "Definition > of a precise exception": > | An exception is described as precise when the exception handler receives the > | PE state and memory system state that is consistent with the PE having > | executed all of the instructions up to but not including the point in the > | instruction stream where the exception was taken, and none afterwards. > | Other than the SError interrupt all exceptions that are taken to AArch32 state > | are required to be precise. For each occurrence of an SError interrupt, > | whether the interrupt is precise or imprecise is IMPLEMENTATION DEFINED. > > >> As it stands today, I see no way to have a self hosted test case that >> exercises that our GISB bus arbiter blocking works correctly because the >> whole kernel is taken down when the test is successful :/ > > Sorry, it looks like your hardware people have given you something you can't > reliably work with. Yes indeed. > > Don't give user-space access to devices, they can take the system down. > Don't punch holes in page mappings, the CPU can't map anything smaller. > Don't respond with an abort unless you are prepared for the OS to die. That much is clear, thank you. -- Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel