Received: by 10.213.65.68 with SMTP id h4csp568357imn; Tue, 13 Mar 2018 13:21:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELsbRtUVMC4XdEAT/thAT01WFu/ROPY8JekqVmTUtDO/xjK/5oe4nHl1+viDi/SBjnhGBffK X-Received: by 2002:a17:902:3001:: with SMTP id u1-v6mr1648657plb.254.1520972502364; Tue, 13 Mar 2018 13:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520972502; cv=none; d=google.com; s=arc-20160816; b=yAzZNf5PWBBFPHFesWc7WNdMaJHZ6MIZytGHqCRwqRDpWsCCmLLzzwmlw7X/B0bU/h scG6ivK7ecAwfs/tC8fTktpmyvDF2K/sUfU1hsnq8zphEM31HqLETylxU8yzTw9YF6yQ y8FnHLlWCfn+fY0hVXP8iGVyY5RXTW0KFBgxWdk6Yi6/bmEM9O3+N4f0HQue12d8+VzX /dpfgy6vHy9LX2oO0cDqrq2AW8Aq/dzpJh7ecc4M1mmPljtvlWx9vK0E/Hzokga2YjaQ cCsBNcbJAm/8W/wBcL90Jv5fh4+rxvvGcv1ro69W/lCz4kl73MWgG4EDKWxs4xsyx0bW RdGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:user-agent :references:in-reply-to:subject:cc:to:from:message-id:date :arc-authentication-results; bh=XY41d0Rvj3GPJ4NM1qPzH+mnOCkYA++SSikTDF0FDUY=; b=TtdoNPbRdzDfks4xaey7U1ZrhcFphyEEB5RXNtaYsCtts6Q+f5marS2JGLmHv7JR2t QSoIeYY1bHVXQ7LxB7DRSF+I1m8jdfCM4hGyYk1OstblOxgL7OUfNJ9r54f8IJA71mtb CFkh9BLsdLw270eJNO+SciqI2+hORFyOEl0DN1ozlD9OQfYcsqn+zTnGk1TtgWJ/QRdM Fe6Bk7yNj5KmWatX016cY0tPbKKF2mV4O8yG+g/3UErCtM0KPzUOvbJtQgodkHs7Pn0M aaLCUdAS4VdrKvMyFHqTnXPMjJBPKpy1ZIEr0l15UXoX9dD9iojx+/9AweUgh8LvhC7W YpzA== 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 q14si616801pgr.311.2018.03.13.13.21.27; Tue, 13 Mar 2018 13:21:42 -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 S1753039AbeCMUT4 (ORCPT + 99 others); Tue, 13 Mar 2018 16:19:56 -0400 Received: from foss.arm.com ([217.140.101.70]:43940 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753013AbeCMUTz (ORCPT ); Tue, 13 Mar 2018 16:19:55 -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 6D5941596; Tue, 13 Mar 2018 13:19:55 -0700 (PDT) Received: from big-swifty.misterjones.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EC7203F53D; Tue, 13 Mar 2018 13:19:53 -0700 (PDT) Date: Tue, 13 Mar 2018 20:19:50 +0000 Message-ID: <86fu53bue1.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Nishanth Menon Cc: Lokesh Vutla , Punit Agrawal , lkml , linux-arm-kernel@lists.infradead.org Subject: Re: [3/3] irqchip/gic-v3: Bounds check redistributor accesses In-Reply-To: References: <20171011094148.15674-4-punit.agrawal@arm.com> <28f9c1cd-e1df-f4db-32b4-c9ca0f0f256a@ti.com> <8366ba39-a5a1-7734-752e-f3dce18e8007@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 13 Mar 2018 18:49:44 +0000, Nishanth Menon wrote: > > Marc, > > On Tue, Mar 13, 2018 at 9:21 AM, Marc Zyngier wrote: > > Hi Lokesh, > > > > On 13/03/18 13:38, Lokesh Vutla wrote: > >> Hi All, > >> > >> On Wednesday 11 October 2017 03:11 PM, Punit Agrawal wrote: > >>> The kernel crashes while iterating over a redistributor that is > >>> in-correctly sized by the platform firmware or doesn't contain the last > >>> record. > >>> > >>> Prevent the crash by checking accesses against the size of the region > >>> provided by the firmware. While we are at it, warn the user about > >>> incorrect region size. > >>> > >>> Signed-off-by: Punit Agrawal > >>> Cc: Marc Zyngier > >> > >> Sorry to bring up an old thread. Just wanted to check what is the status > >> on this series. > > > > So far, I wasn't inclined to merge it, as it only allowed you to detect > > a broken system, as opposed to help with a working one. > > Is'nt that a good reason to have it? Why not help an error in dtb with > a debug helper than an obtuse crash to debug painfully? The kernel is not in the business of validating DTBs. And we both know that if we start papering over firmware bugs, these bugs become ABI, and we live with them forever. If you want to validate DTBs, you should use a tool that is actually validating it against your HW, and not use the kernel as the validation tool. > > > > >> This will also be useful when we try to boot linux + hypervisor with > >> less number of cores than the SoC supports. For example: > >> - SoC has 4 cores and Linux tries to boot with 2 cores. > >> - then a type-2 hypervisor gets installed. > >> - Hypervisor tries to boot a VM with linux on core 1. > >> > >> Now the VM boot will fail while it iterates over all the GICR regions > >> till GICR_TYPER is found. Hypervisor will trap any accesses to GICR > >> regions of any invalid cpus(cpu 2, cpu 3 in this case). > > > > It you're passing the redistributors to a guest, you're doing something > > terribly wrong. You're putting the guest in a position to do a DoS on > > the hypervisor (disabling its timer interrupt, for example). Not the > > greatest move. There is a number of other gotchas with this approach > > (virtual interrupts, distributor virtualization...). > > > >> If the $patch is not the right approach, can you suggest on how to > >> handle the above scenario? > > > > The proper way to handle this is to virtualize the distributor and > > redistributor by trap/emulate. The only thing you can safely pass to a > > guest is the CPU interface, either as system registers or in its MMIO > > form (if you have the GICv2 compatibility interface). > > > > Dumb question: Would'nt a trap emulate be real expensive with hyp > context in v8 (all the context save/restore we'd have to do? (in the > context of discussion, GICV2 compat is disabled). How often do you hit the distributor and redistributors? Why do you need to context switch a distributor that you emulate (hint: you don't). I suggest you look at how real life hypervisor works (there's a pretty good one in the tree). Thanks, M. -- Jazz is not dead, it just smell funny.