Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3938028ybc; Thu, 21 Nov 2019 16:39:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzT/hRjdodY6/eHRFADKACOQphJvcxqBKk7EoPziAZPjKb4Ud+F7NX9DIpUaa97X3nVIGhF X-Received: by 2002:a17:906:2e52:: with SMTP id r18mr18122811eji.178.1574383180735; Thu, 21 Nov 2019 16:39:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574383180; cv=none; d=google.com; s=arc-20160816; b=JSV3XeSFPzMlrRxQT7Aqx+zae8k9HPrn/nbvY5ZHnC6wMVrxCXXbkA379wqTCke0A6 hjI1MuwPZOExYcLEs0lOIMpleVuEwwKX1goQRcmz3x1fStPW+32BYvEIWRsJoTWMv7m3 cnb8djDVSoFZtPOO0s5NbUiBTEzDKo6bKfR6Im3DFaGIWo8JiMkQ4iWF6ovxV3jakCVp M0fIGcnTnI2AJNe6WFbVMV0EAJdSEcZMWdMqhQbWCnTA+VBjtnpEhqpPBA4Nh3xqL16M Tna9HGkgR6KH9gFBxxiK/yiDT4W5BEet0f/uI1H6Uo2HAO/Py/WhLyuYYf2ZOPx0A+Rg kgIg== 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=aNyMrZGi1ytX4T6Y1L2udQxbuMw2fttK87FjgMDAYUk=; b=jB33IIPePbmbgOzAjWluWKgo5NmlyRCRD+IRlE2XN0K6SomVp0dxW87HKwAcqzZ3DY Jdpq6LCs6pJfTOKp+E3cdmegrMSZbscbUdpivhH+JIxdwUKtfd2FhNYUspN1eVoUhqld sqz1TUpg/709PSxZOMvfnufE/aPyV7/rvlS0WCnezN7twvDXppQ2sgsE7NGuIYUSdJi5 4Zv5eIEgPv76lsZVZ+wzt6/45KGjVv127FiO/4SuSSZ54GZL6AWN8XIrwDWuNDZVfITD mMKS6Q112d1t+8mIGoiRytVsBNHl1LcNFt9vdb43qyWFwSv/tVCPmkFfDTdvN2H++1oI sbfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=L+ozNyJ+; 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 e19si2861025ejb.379.2019.11.21.16.39.16; Thu, 21 Nov 2019 16:39:40 -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=L+ozNyJ+; 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 S1726704AbfKVAfp (ORCPT + 99 others); Thu, 21 Nov 2019 19:35:45 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:36360 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbfKVAfo (ORCPT ); Thu, 21 Nov 2019 19:35:44 -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=aNyMrZGi1ytX4T6Y1L2udQxbuMw2fttK87FjgMDAYUk=; b=L+ozNyJ+BLJds7rUUZwTGmJ7R 5e4PdATY1wuc72kBvYhSNqzWkMLSHsiNJaRKKZ+QW6c/CaPxnlL0mM/RPN1bk4jPOFZREl6QSpL4L U3SAD87N8NAF8bzJqfo9CxhGXIHbgmAZZDd6BRqC9ys8sxVq7Xz172xTF71hYopdiv8Ho/rc7y1Yp 9U9/ujkr8zeakeK8TCVh42YDuJelKERsJKDzxphKgN/A7SiBXQtk6Xcx/3Op+FveXgSucAFoCOSum XMJNkFyEpvPjQWNAF0yn6kqWii0P0XsxVVkOtrF7xV1CzBDQeXXUUFjx0ebt5BwyPw9NsN4yUw2ZV 6LjfuU4/g==; Received: from shell.armlinux.org.uk ([2002:4e20:1eda:1:5054:ff:fe00:4ec]:38750) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1iXwuz-0001fH-G7; Fri, 22 Nov 2019 00:35:25 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1iXwuy-0003Cf-Q2; Fri, 22 Nov 2019 00:35:24 +0000 Date: Fri, 22 Nov 2019 00:35:24 +0000 From: Russell King - ARM Linux admin To: Pavel Tatashin Cc: Mark Rutland , Catalin Marinas , stefan@agner.ch, Masahiro Yamada , Will Deacon , boris.ostrovsky@oracle.com, Sasha Levin , sstabellini@kernel.org, James Morris , Linux ARM , xen-devel@lists.xenproject.org, Vladimir Murzin , Marc Zyngier , alexios.zavras@intel.com, Thomas Gleixner , allison@lohutok.net, jgross@suse.com, steve.capper@arm.com, Greg Kroah-Hartman , LKML , James Morse , info@metux.net Subject: Re: [PATCH 1/3] arm/arm64/xen: use C inlines for privcmd_call Message-ID: <20191122003524.GH25745@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> <20191122003403.GG25745@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191122003403.GG25745@shell.armlinux.org.uk> 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 Fri, Nov 22, 2019 at 12:34:03AM +0000, Russell King - ARM Linux admin wrote: > 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. In fact, I'll turn that into a bit more than a suggestion. I'll make it a NAK on adding them to 32-bit ARM. -- 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