Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp520912imu; Thu, 20 Dec 2018 00:31:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/WG5clbLuaYnOtuqlvRQsvMxItYtJRS1A3M6zhYm8VNhIbXz+Ohq0OWJFTfjJyxmV7860P0 X-Received: by 2002:a63:1b48:: with SMTP id b8mr9449048pgm.187.1545294665271; Thu, 20 Dec 2018 00:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545294665; cv=none; d=google.com; s=arc-20160816; b=c3HLtBE2oc6MI8TPFt4ci1rcK9ThSBfNDBd12hdKGDxAIlbA8ecZ25+tzZY6wWVvGN DHEpecKW38hD709XQXpSyw+6H4vLIAI0g6CnhQ8fM1KiMRKuIv7jGgLmCZrVnRJWCb3y JYxn+afqR0m/zuu8SLO5NBna8A8vQ9mjv19PaVg08Wmh/5NTgSp2iaYoG/zV02SI38yf QbGqHydqCFFaOk/Dd6VbG7+/0Zwoye8pHfeIebXTbdD5mNVRrf7Thalmc0dlNustCSDQ ahtd71V6HiZRNGFNqMZpK2Ug0BCOT1Wfmz+6XquClbegStrr5f/ogh/XmGvOeBZgrSic 2eOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+sCQVyYioVzKpHL1i+VhZXvfg7aTUoK422EcOnul4xA=; b=rqFv4+Q5nF3V/KM0FYbs11hcRvrvy7U/I3VO0LovdZ8OHZYo15LtAIsOk417apirLR clbsKvLUJ9g9W3l5/LFRiYLPfKQ4Qs5SqvgCWPekoLPvWV8lLsg1H5bNOng8HQ8dGckh vAznYJLS6u9FJM6OhMpwl3Y/2SlqS5aASuGVQDoViKO+NZgifZzVddkvhPWxM6WyqXzX nkPV6sHNj8g06AKV2CY38og3oNBZnh6CHnpKTpyIQSpb2EyZWiFJXywRVmC7hprtIT2e DsxwBPqRTjnCxFuw11mi/tGuBK35IT4SM6usjg9HiODTYLYUbJaCDZbUL73BUP2NqRlY BOWw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si9468197pgs.126.2018.12.20.00.30.49; Thu, 20 Dec 2018 00:31:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728557AbeLTIZB (ORCPT + 99 others); Thu, 20 Dec 2018 03:25:01 -0500 Received: from ozlabs.ru ([107.173.13.209]:54840 "EHLO ozlabs.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731085AbeLTIY7 (ORCPT ); Thu, 20 Dec 2018 03:24:59 -0500 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id B5A2DAE80381; Thu, 20 Dec 2018 03:24:54 -0500 (EST) From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Cc: Alexey Kardashevskiy , David Gibson , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Alistair Popple , Reza Arbab , Sam Bobroff , Piotr Jaroszynski , =?UTF-8?q?Leonardo=20Augusto=20Guimar=C3=A3es=20Garcia?= , Jose Ricardo Ziviani , Daniel Henrique Barboza , Alex Williamson , Paul Mackerras , linux-kernel@vger.kernel.org, Christoph Hellwig Subject: [PATCH kernel v7 17/20] powerpc/powernv/npu: Fault user page into the hypervisor's pagetable Date: Thu, 20 Dec 2018 19:23:47 +1100 Message-Id: <20181220082350.58113-18-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181220082350.58113-1-aik@ozlabs.ru> References: <20181220082350.58113-1-aik@ozlabs.ru> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a page fault happens in a GPU, the GPU signals the OS and the GPU driver calls the fault handler which populated a page table; this allows the GPU to complete an ATS request. On the bare metal get_user_pages() is enough as it adds a pte to the kernel page table but under KVM the partition scope tree does not get updated so ATS will still fail. This reads a byte from an effective address which causes HV storage interrupt and KVM updates the partition scope tree. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/npu-dma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c index c6163b9..12b8421 100644 --- a/arch/powerpc/platforms/powernv/npu-dma.c +++ b/arch/powerpc/platforms/powernv/npu-dma.c @@ -1133,6 +1133,8 @@ int pnv_npu2_handle_fault(struct npu_context *context, uintptr_t *ea, u64 rc = 0, result = 0; int i, is_write; struct page *page[1]; + const char __user *u; + char c; /* mmap_sem should be held so the struct_mm must be present */ struct mm_struct *mm = context->mm; @@ -1145,18 +1147,17 @@ int pnv_npu2_handle_fault(struct npu_context *context, uintptr_t *ea, is_write ? FOLL_WRITE : 0, page, NULL, NULL); - /* - * To support virtualised environments we will have to do an - * access to the page to ensure it gets faulted into the - * hypervisor. For the moment virtualisation is not supported in - * other areas so leave the access out. - */ if (rc != 1) { status[i] = rc; result = -EFAULT; continue; } + /* Make sure partition scoped tree gets a pte */ + u = page_address(page[0]); + if (__get_user(c, u)) + result = -EFAULT; + status[i] = 0; put_page(page[0]); } -- 2.17.1