mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
	loongson-kernel@lists.loongnix.cn
Subject: Re: [PATCH v1 4/6] objtool/LoongArch: Enable orc to be built
Date: Tue, 25 Jul 2023 13:51:06 +0200	[thread overview]
Message-ID: <20230725115106.GC3765278@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <1690272910-11869-5-git-send-email-yangtiezhu@loongson.cn>

On Tue, Jul 25, 2023 at 04:15:08PM +0800, Tiezhu Yang wrote:

Previous Changelog had:

> Define update_cfi_state() as a weak function which may be overwritten
> by the arch-specific implementation.

And then this patch does:

> +int update_cfi_state(struct instruction *insn,
> +		     struct instruction *next_insn,
> +		     struct cfi_state *cfi, struct stack_op *op)
> +{
> +	struct cfi_reg *cfa = &cfi->cfa;
> +	struct cfi_reg *regs = cfi->regs;
> +
> +	/* ignore UNWIND_HINT_UNDEFINED regions */
> +	if (cfi->force_undefined)
> +		return 0;
> +
> +	/* stack operations don't make sense with an undefined CFA */
> +	if (cfa->base == CFI_UNDEFINED) {
> +		if (insn_func(insn)) {
> +			WARN_INSN(insn, "undefined stack state");
> +			return -1;
> +		}
> +		return 0;
> +	}
> +
> +	if (cfi->type == UNWIND_HINT_TYPE_REGS ||
> +	    cfi->type == UNWIND_HINT_TYPE_REGS_PARTIAL)
> +		return update_cfi_state_regs(insn, cfi, op);
> +
> +	switch (op->dest.type) {
> +	case OP_DEST_REG:
> +		switch (op->src.type) {
> +		case OP_SRC_ADD:
> +			if (op->dest.reg == CFI_SP && op->src.reg == CFI_SP) {
> +				/* addi.d sp,sp,si12 */
> +				cfi->stack_size -= op->src.offset;
> +				if (cfa->base == CFI_SP)
> +					cfa->offset -= op->src.offset;
> +			} else if (op->dest.reg == CFI_FP && op->src.reg == CFI_SP) {
> +				/* addi.d fp,sp,si12 */
> +				if (cfa->base == CFI_SP && cfa->offset == op->src.offset) {
> +					cfa->base = CFI_FP;
> +					cfa->offset = 0;
> +				}
> +			} else if (op->dest.reg == CFI_SP && op->src.reg == CFI_FP) {
> +				/* addi.d sp,fp,si12 */
> +				if (cfa->base == CFI_FP && cfa->offset == 0) {
> +					cfa->base = CFI_SP;
> +					cfa->offset = -op->src.offset;
> +				}
> +			}
> +			break;
> +		case OP_SRC_REG_INDIRECT:
> +			/* ld.d rd,sp,si12 */
> +			if (op->src.reg == CFI_SP &&
> +			    op->src.offset == (regs[op->dest.reg].offset + cfi->stack_size)) {
> +				restore_reg(cfi, op->dest.reg);
> +				/* GCC may not restore sp, we adjust it directly. */
> +				if (cfa->base == CFI_FP && cfa->offset == 0) {
> +					cfa->base = CFI_SP;
> +					cfa->offset = cfi->stack_size;
> +				}
> +			}
> +			break;
> +		default:
> +			break;
> +		}
> +		break;
> +	case OP_DEST_REG_INDIRECT:
> +		if (op->src.type == OP_SRC_REG)
> +			/* st.d rd,sp,si12 */
> +			if (op->dest.offset)
> +				save_reg(cfi, op->src.reg, CFI_CFA,
> +					 op->dest.offset - cfi->stack_size);
> +		break;
> +	default:
> +		WARN_FUNC("unknown stack-related instruction", insn->sec, insn->offset);
> +		return -1;
> +	}
> +
> +	return 0;
> +}

Why ?!? what is the actual irreconcilable difference?

If you want us to review this, you'll have to explain things.

  reply	other threads:[~2023-07-25 11:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25  8:15 [PATCH v1 0/6] Add objtool and orc support for LoongArch Tiezhu Yang
2023-07-25  8:15 ` [PATCH v1 1/6] objtool/LoongArch: Enable objtool to be built Tiezhu Yang
2023-07-25  8:15 ` [PATCH v1 2/6] objtool/LoongArch: Implement instruction decoder Tiezhu Yang
2023-07-25  8:15 ` [PATCH v1 3/6] objtool/x86: Separate arch-specific and generic parts Tiezhu Yang
2023-07-25  8:15 ` [PATCH v1 4/6] objtool/LoongArch: Enable orc to be built Tiezhu Yang
2023-07-25 11:51   ` Peter Zijlstra [this message]
2023-07-27 10:58     ` Tiezhu Yang
2023-07-25 11:56   ` Peter Zijlstra
2023-07-28  1:31     ` Tiezhu Yang
2023-07-25  8:15 ` [PATCH v1 5/6] objtool: Add skipped member in struct reloc Tiezhu Yang
2023-07-25 11:59   ` Peter Zijlstra
2023-08-03 11:36     ` Tiezhu Yang
2023-08-03 12:11       ` Peter Zijlstra
2023-08-09 11:51         ` Xi Ruoyao
2023-08-09 11:58           ` Xi Ruoyao
2023-07-25  8:15 ` [PATCH v1 6/6] LoongArch: Add ORC unwinder support Tiezhu Yang
2023-07-25 12:01 ` [PATCH v1 0/6] Add objtool and orc support for LoongArch Peter Zijlstra
2023-08-09  9:55   ` Tiezhu Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230725115106.GC3765278@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=chenhuacai@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=loongson-kernel@lists.loongnix.cn \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®