From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C1DAC433DF for ; Tue, 16 Jun 2020 10:32:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F5EF20767 for ; Tue, 16 Jun 2020 10:32:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="oOVDATDT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728250AbgFPKby (ORCPT ); Tue, 16 Jun 2020 06:31:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726606AbgFPKbp (ORCPT ); Tue, 16 Jun 2020 06:31:45 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48E83C08C5C2; Tue, 16 Jun 2020 03:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Gh7RFTXOWWEwXkqUOJF0XcAnRZHVHCKl/wuld2I2MhA=; b=oOVDATDTspIuLa58Sihodo+6rS 8l3QSIsv3BJTw5olTRniYjVZvBpLQmpDhVXlrN4ZndTR5hoxhJoejBG2gVTtYKxRcxKC7etvmwlEb gWLQIz17AakGEAJXJfZc2PhbtoNaWKnPm0HWow/HwIXlJu7JQBZsTrNAoAgDNEG5TJfsYAoXUm9/M 62htO08TiKopeDwpiNEeBIIVAmsGB+CYQw+MoGV6AYrvkeRFD4NdoQd56m8KQy4uLMWpQuVlrY6Bo FjB8o1+FzGmmO8KsmISS4Roarxc5kGzvT2BNZG9vxxxbLAKq2Vsm3Xp0/s8IR1VLKVZYDV0sC0jM2 2Q1VTIpQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jl8sV-0004v2-AK; Tue, 16 Jun 2020 10:31:39 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 971833017B7; Tue, 16 Jun 2020 12:31:37 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 822E22022DEBD; Tue, 16 Jun 2020 12:31:37 +0200 (CEST) Date: Tue, 16 Jun 2020 12:31:37 +0200 From: Peter Zijlstra To: Christoph Hellwig Cc: Dexuan Cui , vkuznets , Stephen Hemminger , Andy Lutomirski , Andy Lutomirski , Michael Kelley , Ju-Hyoung Lee , "x86@kernel.org" , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , KY Srinivasan , Tom Lendacky Subject: Re: hv_hypercall_pg page permissios Message-ID: <20200616103137.GQ2531@hirez.programming.kicks-ass.net> References: <20200407073830.GA29279@lst.de> <87y2ooiv5k.fsf@vitty.brq.redhat.com> <20200616072318.GA17600@lst.de> <20200616101807.GO2531@hirez.programming.kicks-ass.net> <20200616102350.GA29684@lst.de> <20200616102412.GB29684@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200616102412.GB29684@lst.de> Sender: linux-hyperv-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hyperv@vger.kernel.org On Tue, Jun 16, 2020 at 12:24:12PM +0200, Christoph Hellwig wrote: > On Tue, Jun 16, 2020 at 12:23:50PM +0200, Christoph Hellwig wrote: > > > + hv_hypercall_pg = module_alloc(PAGE_SIZE); > > > if (hv_hypercall_pg == NULL) { > > > wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0); > > > goto remove_cpuhp_state; > > > } > > > > > > + set_memory_ro((unsigned long)hv_hypercall_pg, 1); > > > + set_memory_x((unsigned long)hv_hypercall_pg, 1); > > > > The changing of the permissions sucks. I thought about adding > > a module_alloc_prot with an explicit pgprot_t argument. On x86 > > alone at least ftrace would also benefit from that. How would ftrace benefit from a RX permission? We need to actually write to the page first. This HV thing is special in that it lets the host write. > The above is also missing a set_vm_flush_reset_perms. Ah, indeed. Otherwise we don't clean up properly.