Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3935083ybc; Thu, 21 Nov 2019 16:35:44 -0800 (PST) X-Google-Smtp-Source: APXvYqz7HIS9CQ4nuDxnvWXvxHLDayTGQhhse2Ek8BKHEvcydgGiQUGN1g1hJnLX1btrIeJYMIAt X-Received: by 2002:a17:906:4bd7:: with SMTP id x23mr17585765ejv.245.1574382944828; Thu, 21 Nov 2019 16:35:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574382944; cv=none; d=google.com; s=arc-20160816; b=mgbzMa0iPO3IqpZe7F6v+5tWhMi9imF9mf+9lkzoomDS6bfY4ZkovCh+DQr9Ny2+KZ yQMX1KX31fLz+BSm8v52hhcVvM0zOFDXUMrZAef8BeHK5p16RCkXndD2Xe/H2Fpsovy7 2PO2uQE4fyOExMuLiza0mvIf32BhBGwHkyzT6ts8SF8s0+DeiBUNwBCwC89S8MzBtxCd OdS50FMT8fgzRBIA5CR8fXPB+3b5iH6Z2PSRl+F4HRbshpUnruTJizqWgZCEldq6dzrA rswQRWr15a6dUcXS5Fbo0RzajTI3sr1Qf7b8DoAYz+Vyq7OTGFdO5aAtRKBlMO1bxzwm zTqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YL9UjrFzkCb8yeKfLOoIaW9TGt9+B8/y4tvJ5xKe8SE=; b=CfiISETZSZW9xWBEXF1AwQlsDuY4uuv/NrrNHpcCl1RkJIRU9LkTQUUx2Nn2MhDLOA ufD14csGYJ0aPKOq0dFgsmQmPeDY6YQA9iQ54vq0cuI76aZNoKhZAPBGWuu0hEGlIPtN 45J9fcNiur3iJ0qI9l3fJ6xC9T9NSGEXOruXfAWObNunvbIG1FerGMnCAFZLOZWrI2uc RiZgbPr29GD1m0EK2UsVCCNRavOGmbGLjxypfkJayU3k+I8npD6QtAhfknEY/+Azkigb 5mS5F89TQ6EO2gH/hwvDBQQnc/Micw66L3UYQ55bHUWEcs7Esz3/tYoFUexwKk/ZoRfV DpaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=BLzrPF7J; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si3020581ejj.307.2019.11.21.16.35.20; Thu, 21 Nov 2019 16:35:44 -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; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=BLzrPF7J; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726510AbfKVAeN (ORCPT + 99 others); Thu, 21 Nov 2019 19:34:13 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:36278 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbfKVAeM (ORCPT ); Thu, 21 Nov 2019 19:34:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=YL9UjrFzkCb8yeKfLOoIaW9TGt9+B8/y4tvJ5xKe8SE=; b=BLzrPF7JJVK/eQcSltF4pPT2H PNsjDKHbMyIPQt75OFD/xgt3Tran+t5t0JIl5n6NN5YV+rxoah/hQUcmbGwTcSHpVcL8gAB0ZqiSR 3LqM+kxQu/0Oku48ZcpF17NSbkzCJmq5Vwcd8iGwI8tAxol1gULqUV8XJ1m924k97RK9bv/kGXFqb uKWRfp0mFUtW70cmQpzJSn8pqHW+NhtKzsSeMGZ1Qkwjc8tEbfYH6pv6aE+rZdLv8Io+sskEYleRZ rXGierSb3mbTZWA/k+2Mr4QKfJSorBdj9NjjUl56cMpEgCbwNXsOh0MU7deZIV5PBv7LQKlaozHFA ADu5Y77EA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:42888) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1iXwth-0001eL-2J; Fri, 22 Nov 2019 00:34:05 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1iXwtf-0003CX-5J; Fri, 22 Nov 2019 00:34:03 +0000 Date: Fri, 22 Nov 2019 00:34:03 +0000 From: Russell King - ARM Linux admin To: Pavel Tatashin Cc: James Morris , Sasha Levin , LKML , Catalin Marinas , Will Deacon , steve.capper@arm.com, Linux ARM , Marc Zyngier , James Morse , Vladimir Murzin , Mark Rutland , Thomas Gleixner , Greg Kroah-Hartman , allison@lohutok.net, info@metux.net, alexios.zavras@intel.com, sstabellini@kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, stefan@agner.ch, Masahiro Yamada , xen-devel@lists.xenproject.org Subject: Re: [PATCH 1/3] arm/arm64/xen: use C inlines for privcmd_call Message-ID: <20191122003403.GG25745@shell.armlinux.org.uk> References: <20191121184805.414758-1-pasha.tatashin@soleen.com> <20191121184805.414758-2-pasha.tatashin@soleen.com> <20191122002258.GD25745@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 21, 2019 at 07:30:41PM -0500, Pavel Tatashin wrote: > > > +#ifdef CONFIG_CPU_SW_DOMAIN_PAN > > > +static __always_inline void uaccess_enable(void) > > > +{ > > > + unsigned long val = DACR_UACCESS_ENABLE; > > > + > > > + asm volatile("mcr p15, 0, %0, c3, c0, 0" : : "r" (val)); > > > + isb(); > > > +} > > > + > > > +static __always_inline void uaccess_disable(void) > > > +{ > > > + unsigned long val = DACR_UACCESS_ENABLE; > > Oops, should be DACR_UACCESS_DISABLE. > > > > + > > > + asm volatile("mcr p15, 0, %0, c3, c0, 0" : : "r" (val)); > > > + isb(); > > > +} > > > > Rather than inventing these, why not use uaccess_save_and_enable().. > > uaccess_restore() around the Xen call? > > Thank you for suggestion: uaccess_enable() and uaccess_disable() are > common calls with arm64, so I will need them, but I think I can use > set_domain() with DACR_UACCESS_DISABLE /DACR_UACCESS_ENABLE inside > these inlines. That may be, but be very careful that you only use them in ARMv7-only code. Using them elsewhere is unsafe as the domain register is used for other purposes, and merely blatting over it (as your uaccess_enable and uaccess_disable functions do) is unsafe. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up