Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2340397ybt; Tue, 16 Jun 2020 03:35:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHmaENPj5LKA/0FlpImTkT8hPqv2kFmKXUejwYzqlZf7jRJDCbIqRN0cL8UHaxs0KzjAhs X-Received: by 2002:a17:906:840d:: with SMTP id n13mr2080220ejx.49.1592303722564; Tue, 16 Jun 2020 03:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592303722; cv=none; d=google.com; s=arc-20160816; b=WuIP8qtCMuyA08cAuSPSmS9ta03+P0bbOAilABYzU9peOQh/GJo/ppGtYW0cUQB8Gn nLwOro8jfxVedWjT5lrFbC7syk1K7Z42iAvfx2GMtkwArgbGow7DGXNsrSxXaSGOYLNp Y2ioPYEJ+Rpm9C8DpLRbQY9y/gM02Ps3z8WhSEZFG4b3bbsoQxElPfPW5RsEDYep19NY QjUS2zee/D6MiRIuKlIGHg3bhZM1hkHCyova/YxlhwnGtaRw9/nXCL0D4rVPL96V4wFa ReuvJEQChK0tZDcxCopY99BOwTrtFEfo2rm04Oe0Avko/hLgbs80PFUL6LlfM2CJ3UQP Kb7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Gh7RFTXOWWEwXkqUOJF0XcAnRZHVHCKl/wuld2I2MhA=; b=K1HCFxnXyxmy2M/KLCTc3YX2wL6idNXbWTnPpk0hDwSngavjW9IzcM7vN5mzlCjzts GoKE94MxyNEndJJHcqVSYPlCkX7rex6MNtccttSqJRp2LsutdYrfrsCUeqTat8Ueu7g0 n9WxTnkGv1WyuPXaB5STniTDwV0N+FX1/ebSt81aks6hAgZmbVDiePrVtzKEKw5rACB7 L/U/eGe0oaHzYyKwQkrwyfMxxAxvzgrYGW3DNCuMPaOGa94lfMYmpJDiWIMi6UmQ68Fr RTCNmKAlqoqxfiHUp2EJpFe97xPfmM2F3W+A+JtUXcsS9Mv19WxfU535s3v+q+lVeoah mbeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oOVDATDT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y33si6510808edy.206.2020.06.16.03.35.00; Tue, 16 Jun 2020 03:35:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oOVDATDT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728264AbgFPKcM (ORCPT + 99 others); Tue, 16 Jun 2020 06:32:12 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.