From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753136AbbIKPUx (ORCPT ); Fri, 11 Sep 2015 11:20:53 -0400 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:41258 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752167AbbIKPUv (ORCPT ); Fri, 11 Sep 2015 11:20:51 -0400 Date: Fri, 11 Sep 2015 16:20:34 +0100 From: Russell King - ARM Linux To: Julien Grall Cc: Ian Campbell , xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org, stefano.stabellini@eu.citrix.com, linux-kernel@vger.kernel.org, Riku Voipio Subject: Re: [PATCH] arm/xen: Enable user access to the kernel before issuing a privcmd call Message-ID: <20150911152034.GT21084@n2100.arm.linux.org.uk> References: <1441980963-9002-1-git-send-email-julien.grall@citrix.com> <1441981760.3549.57.camel@citrix.com> <55F2E909.70600@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55F2E909.70600@citrix.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 11, 2015 at 03:45:29PM +0100, Julien Grall wrote: > Looking to the uaccess_save macro: > > .macro uaccess_save, tmp > #ifdef CONFIG_CPU_SW_DOMAIN_PAN > mrc p15, 0, \tmp, c3, c0, 0 > str \tmp, [sp, #S_FRAME_SIZE] > #endif > .endm > > > It's saving the register on the Stack with an offset S_FRAME_SIZE. > AFAICT, S_FRAME_SIZE is the size of the pt_regs structure. While in the kernel, the uaccess state will be disabled except for the specific sites reading or writing userspace. That means the user-access part of the DACR is well known. What isn't known is whether we're executing here in the kernel segment (set_fs(get_ds())) or not - which allows the kernel to use the userspace accessors to safely read from its own memory space. If we can assume that's not in effect, then the DACR value is fully known at this point, and you can just do a: uaccess_enable rtmp HVC call uaccess_disable rtmp where rtmp is a register you can afford to be changed by the macro. I suspect 'ip' would be a good choice there. Please put the macros as close to __HVC(XEN_IMM) as possible. Thanks. -- FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.