Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9227839imu; Wed, 5 Dec 2018 00:55:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/UBAfCTkDWunVUbp++hkl3/TTQ2GoYXZX6txArbsu0JbxAWT3OI0falDMsIm/oI6bBhreUg X-Received: by 2002:a62:7652:: with SMTP id r79mr24320819pfc.241.1544000127518; Wed, 05 Dec 2018 00:55:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544000127; cv=none; d=google.com; s=arc-20160816; b=Oy53JWSNP1CBPVPdLpV/TOvudZo9H80oS2wQ7XNOY1zAutZvnoC3dqfAj5+/zD7+SO HQ4GrdkYGNsFbGRRie5av3jx4aP1TqsLZb9lVv34vGR8buxFUOW4ZyDGibC3xgtS7sIu nLt00uQQYiQRmDKAKe2x7JA2udsRjX1r67b/3Doc6AV9V+kmrXCDHbIQo82ZAA5unjBG +ea4hzPyaAqfbxKdDXOMYvMTpUXp9Bmin20hkgOBIPsLunufwIktBqVSPyk4EqaGBGrt lemDfJ1lK5sKJGk7i6Iwtz088oQNSph8oUgXRF/CcZZNOt8dWwvWvsAzICKx19Ttlbv8 wWlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=LHkh0CTtBk7FNlgzZ8w3lLIEZK/0GZluK3ZNBfgqUCc=; b=Ahf4J+U1rzr1HRq3Z2ILaFvcW15YkxQqMWrcD3kTSKmncGud+u1Cln8EHiUaZiGR7Q MYZbuiAMS+jxhp3DgaPjI0VSxAvpxcxWQSqkpq1UAEBTCiCLdujz0m550NnSY4HRLm5Q p/lbiVyNLaYhH9gpsFzl0TXG5tzpM1co6ZIiLTWd/X9BNGl18j2VCKSRddjFjWBY3m9e zcDFE0UQXQXnSeE57xzst11rtgYaZ7KfH7TNCIKjTdyMxlvCGi+fDsM9wuIrwD+taix5 8+yV+0Qsx0HKJRxITg1cV1R+ghFQQpFYh5g52jaRxTiUPXLtj/ZG8jt9B+3pTcXooBKZ rdbQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si17662514pgi.531.2018.12.05.00.55.12; Wed, 05 Dec 2018 00:55:27 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbeLEIxD (ORCPT + 99 others); Wed, 5 Dec 2018 03:53:03 -0500 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:46460 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726351AbeLEIwK (ORCPT ); Wed, 5 Dec 2018 03:52:10 -0500 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 5 Dec 2018 00:52:03 -0800 Received: from sc2-haas01-esx0118.eng.vmware.com (sc2-haas01-esx0118.eng.vmware.com [10.172.44.118]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 14F8741394; Wed, 5 Dec 2018 00:52:05 -0800 (PST) From: Nadav Amit To: Ingo Molnar CC: , , "H. Peter Anvin" , Thomas Gleixner , Borislav Petkov , Andy Lutomirski , Nadav Amit , Dave Hansen , Peter Zijlstra , , , , Nadav Amit Subject: [PATCH v7 07/14] x86/kgdb: avoid redundant comparison of patched code Date: Tue, 4 Dec 2018 17:34:01 -0800 Message-ID: <20181205013408.47725-8-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181205013408.47725-1-namit@vmware.com> References: <20181205013408.47725-1-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-002.vmware.com: namit@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org text_poke() already ensures that the written value is the correct one and fails if that is not the case. There is no need for an additional comparison. Remove it. Signed-off-by: Nadav Amit --- arch/x86/kernel/kgdb.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c index 2636ca8394bd..86484510bf54 100644 --- a/arch/x86/kernel/kgdb.c +++ b/arch/x86/kernel/kgdb.c @@ -751,7 +751,6 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long ip) int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) { int err; - char opc[BREAK_INSTR_SIZE]; bpt->type = BP_BREAKPOINT; err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr, @@ -770,11 +769,6 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) return -EBUSY; text_poke_kgdb((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE); - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE); - if (err) - return err; - if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE)) - return -EINVAL; bpt->type = BP_POKE_BREAKPOINT; return err; @@ -782,9 +776,6 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) { - int err; - char opc[BREAK_INSTR_SIZE]; - if (bpt->type != BP_POKE_BREAKPOINT) goto knl_write; /* @@ -795,10 +786,7 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) goto knl_write; text_poke_kgdb((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE); - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE); - if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE)) - goto knl_write; - return err; + return 0; knl_write: return probe_kernel_write((char *)bpt->bpt_addr, -- 2.17.1