Received: by 10.223.176.5 with SMTP id f5csp2283621wra; Mon, 5 Feb 2018 01:09:50 -0800 (PST) X-Google-Smtp-Source: AH8x2262aprJhkBzqBBj+jWgp8ZWAADVQzZu6XEI8yMDIROJmna55NUaDmr+GuAHOcZ/DuobpCHF X-Received: by 10.98.219.129 with SMTP id f123mr48708701pfg.51.1517821789988; Mon, 05 Feb 2018 01:09:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517821789; cv=none; d=google.com; s=arc-20160816; b=hSPTPbae0dLc42xvueLsbSiQK+EPUiKcMfbBZTFNzHZEXQNASCDLlB2FXZCbgja2r0 YIYyuWRK+EnIkkJhMQb4bOCZnIR2ujWAS0L/us2S0fVICiBC/T/tQP1BrLa68DpdfbsY n0Rt2YUFCIiNSS6fDlpW+SpE5PbaF0ulRwE4C3a6RO6KwKLMyShHLTe3zmUn6tGv2y1B bl4Prs++TnF+piDiaO2UniiSV5K97P57kQo+23Kbmgf+ocfCEFEirTDTVakFLbDof1Bk 1OGT24pvr1l/uL6t+iTKsXFIHWlljBeV0qN9aavO2aQrLHmIAsjomn5MYzhGnXwzj642 YwSg== 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:organization:from:references:cc:to:subject :arc-authentication-results; bh=spUQxiSSSjAVioTMvi31FrwRefIYM6iHIinpo52W7Mw=; b=cEKbIHRh6IEjguGHmOvopiihZUxhEd6n2I7WEEej4g8frvvptxTi23UoViFxM1Sa02 N0wAGehBCib/mbJR87LZnfdHseK+B/OBaufBKa2yjrnJdV+gcEM6AhCZCjDrwRRku+x+ bGZa1qGc+k9NEEhiq1QnwGkYi5sheRKgNFWCGamuvBszynz7aFYFKBAaXkpPCRBl60DC ugAC6Idyq6bIVC/bnP2CacpjaOIKEwsP9rX4Fi6abQ52TcZqeespKquWudrb/TDfWTWa kxJzl7LNFxFBJP41GQulWPJoMnnNpuHXcduLpcup8Mf19hslQ1wU5lg7lCvEj1xmnKHn OqUw== 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 g16si795075pfh.248.2018.02.05.01.09.35; Mon, 05 Feb 2018 01:09:49 -0800 (PST) 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 S1752612AbeBEJIm (ORCPT + 99 others); Mon, 5 Feb 2018 04:08:42 -0500 Received: from foss.arm.com ([217.140.101.70]:47756 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949AbeBEJIg (ORCPT ); Mon, 5 Feb 2018 04:08:36 -0500 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 7EE551529; Mon, 5 Feb 2018 01:08:35 -0800 (PST) Received: from [10.1.207.62] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF3963F53D; Mon, 5 Feb 2018 01:08:32 -0800 (PST) Subject: Re: [PATCH v3 12/18] arm64: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling To: Christoffer Dall Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Catalin Marinas , Will Deacon , Peter Maydell , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux References: <20180201114657.7323-1-marc.zyngier@arm.com> <20180201114657.7323-13-marc.zyngier@arm.com> <20180204183907.GP21802@cbox> From: Marc Zyngier Organization: ARM Ltd Message-ID: <1d30fe51-22dd-6938-2f8f-c823858a3bbd@arm.com> Date: Mon, 5 Feb 2018 09:08:31 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180204183907.GP21802@cbox> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/02/18 18:39, Christoffer Dall wrote: > On Thu, Feb 01, 2018 at 11:46:51AM +0000, Marc Zyngier wrote: >> We want SMCCC_ARCH_WORKAROUND_1 to be fast. As fast as possible. >> So let's intercept it as early as we can by testing for the >> function call number as soon as we've identified a HVC call >> coming from the guest. > > Hmmm. How often is this expected to happen and what is the expected > extra cost of doing the early-exit handling in the C code vs. here? Pretty often. On each context switch of a Linux guest, for example. It is almost as bad as if we were trapping all VM ops. Moving it to C is definitely visible on something like hackbench (I remember something like a 10-12% degradation on Seattle, but I'd need to rerun the tests to give you something accurate). It is the whole GPR save/restore dance that costs us a lot (31 registers for the guest, 12 for the host), plus some the extra SError synchronization that doesn't come for free either. > I think we'd be better off if we only had a single early-exit path (and > we should move the FP/SIMD trap to that path as well), but if there's a > measurable benefit of having this logic in assembly as opposed to in the > C code, then I'm ok with this as well. I agree that the multiplication of "earlier than early" paths is becoming annoying. Moving the FP/SIMD stuff to C would be less problematic, as we have patches to move some of that to load/put, and we'd only take the trap once per time slice (as opposed to once per entry at the moment). Here, we're trying hard to do exactly nothing, because each instruction is just an extra overhead (we've already nuked the BP). I even considered inserting that code as part of the per-CPU-type vectors (and leave the rest of the KVM code alone), but it felt like a step too far. > The code in this patch looks fine otherwise. Thanks, M. -- Jazz is not dead. It just smells funny...