Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3372255ybt; Tue, 30 Jun 2020 00:44:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvwcPBXB2S9MymNgjbXfc+UKHQu/nxoVlgP1lGEz9Mjl6bqt47MtgIcy5e4zytmiabh7En X-Received: by 2002:a17:906:71c6:: with SMTP id i6mr17878206ejk.103.1593503046408; Tue, 30 Jun 2020 00:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593503046; cv=none; d=google.com; s=arc-20160816; b=u1UxhpnoOioA1a8P0PB5E5mOxngZ3SG2C72gTWjnyj8lXKBekYwqs2DO2NC0Dps42z m6CzAr3CEOZYbhmwJQaIND/ChIaanRmcu12qazbQ3i6N/yiwWQjuH42lm3qCGojNTzaq FPfn0MYg3MhSP+uyKzeVh9gwcX9MkeeFyMK11dWGD1iOsBLEL9Aek42GERKwUUTAQzVM VwJ9K0rKIzy+6S2QJgWlNcTMfYZK+hsqCE9nzUMbQwUy3XZ/ehDohKfikDQ3HwucpxHE 6O6LMZcsPhaRd1bxFqnyOQp48lfaowa0zScholplCTIQIg9JP+q+BZqufvm8INbG61U8 RZWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=XuCj/rvw5LIpNvYsm9q/luTXMKDlVM8o3tLFjJyek/Y=; b=CfZRDg90kmpX5E9mUkaM4rZcc8Oh8pDOHLxvDwY5YvmrdfiK1e229M7m8lSsdbOq2Q au73ka2zQjcTlo9KCJVNWi7kJWHpcGXsTX3Iyd9HySnL+h4+VUHpEzveAuSKIJXQ2WjI SUUy1mTHH3/p6Fw422gw6RsZXuu47bmRMBNcnU/UMyoYufMj07HPxrMqigZKk+LsZe6i LGCcNjk5LF5PHVxQfKImDajOwM4r/XxA/bajA0U2ZOrVDPrFd/yhxUVPEJfdbcZwqUo1 6UY/7cpcHySfpktoy9pXSip0IoiUaSp/NsCDfFnMeykoAvE4KSXWngj4I4TpAUTcDceL gPSg== ARC-Authentication-Results: i=1; mx.google.com; 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 m4si1316341ejo.514.2020.06.30.00.43.43; Tue, 30 Jun 2020 00:44:06 -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; 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 S1731209AbgF3HnS (ORCPT + 99 others); Tue, 30 Jun 2020 03:43:18 -0400 Received: from smtp25.cstnet.cn ([159.226.251.25]:43078 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731198AbgF3HnQ (ORCPT ); Tue, 30 Jun 2020 03:43:16 -0400 Received: from localhost (unknown [159.226.5.99]) by APP-05 (Coremail) with SMTP id zQCowADHFCQD7fpeXVqiAQ--.32278S2; Tue, 30 Jun 2020 15:42:59 +0800 (CST) From: Chen Ni To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org Cc: linux-kernel@vger.kernel.org, Xu Wang Subject: [PATCH] kernel: events: use offset_in_page macro Date: Tue, 30 Jun 2020 07:42:58 +0000 Message-Id: <20200630074258.8301-1-vulab@iscas.ac.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: zQCowADHFCQD7fpeXVqiAQ--.32278S2 X-Coremail-Antispam: 1UD129KBjvJXoWxJrWfCF47KFy3KF1ftFWxtFb_yoW8JFWfpF 45Ja98tw43K3W8Ka47Ar1kuw15twn7KrW8ta42k34F9r1vgw1rZ3WxGr47XFWFg392gr4U ta1DWr98Aa1kZ3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkm14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1q6rW5McIj6I8E87Iv67AKxVWaoVW8JcWlOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_GF4l 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r 4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUFID7DUUUU X-Originating-IP: [159.226.5.99] X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiCAIDA102YPg8PQAAs4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu Wang Use offset_in_page macro instead of (addr & ~PAGE_MASK). Signed-off-by: Xu Wang --- kernel/events/uprobes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index bb0862873dba..44d175d81ed6 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -244,14 +244,14 @@ bool __weak is_trap_insn(uprobe_opcode_t *insn) static void copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len) { void *kaddr = kmap_atomic(page); - memcpy(dst, kaddr + (vaddr & ~PAGE_MASK), len); + memcpy(dst, kaddr + offset_in_page(vaddr), len); kunmap_atomic(kaddr); } static void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len) { void *kaddr = kmap_atomic(page); - memcpy(kaddr + (vaddr & ~PAGE_MASK), src, len); + memcpy(kaddr + offset_in_page(vaddr), src, len); kunmap_atomic(kaddr); } @@ -387,7 +387,7 @@ __update_ref_ctr(struct mm_struct *mm, unsigned long vaddr, short d) } kaddr = kmap_atomic(page); - ptr = kaddr + (vaddr & ~PAGE_MASK); + ptr = kaddr + offset_in_page(vaddr); if (unlikely(*ptr + d < 0)) { pr_warn("ref_ctr going negative. vaddr: 0x%lx, " -- 2.17.1